mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-12 18:49:41 -04:00
fix: remove --publish-branch with branch name to npm publish args (#3107)
close #2996 * fix: remove --publish-branch with branch name to npm publish args * Update packages/plugin-commands-publishing/src/publish.ts Co-authored-by: Zoltan Kochan <zkochan@users.noreply.github.com> Co-authored-by: Zoltan Kochan <zkochan@users.noreply.github.com>
This commit is contained in:
5
.changeset/proud-snakes-destroy.md
Normal file
5
.changeset/proud-snakes-destroy.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-publishing": patch
|
||||
---
|
||||
|
||||
fix: remove --publish-branch with branch name to npm publish args
|
||||
@@ -164,7 +164,20 @@ Do you want to continue?`,
|
||||
'prepack',
|
||||
], publishManifest)
|
||||
}
|
||||
const { status } = runNpm(opts.npmPath, ['publish', '--ignore-scripts', ...opts.argv.original.slice(1)])
|
||||
|
||||
const args = opts.argv.original.slice(1)
|
||||
const index = args.indexOf('--publish-branch')
|
||||
if (index !== -1) {
|
||||
// If --publish-branch follows with another cli option, only remove this argument
|
||||
// otherwise remove the following argument as well
|
||||
if (args[index + 1]?.startsWith('-')) {
|
||||
args.splice(index, 1)
|
||||
} else {
|
||||
args.splice(index, 2)
|
||||
}
|
||||
}
|
||||
|
||||
const { status } = runNpm(opts.npmPath, ['publish', '--ignore-scripts', ...args])
|
||||
if (!opts.ignoreScripts) {
|
||||
await _runScriptsIfPresent([
|
||||
'publish',
|
||||
|
||||
@@ -2,6 +2,7 @@ import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import prepare, { preparePackages } from '@pnpm/prepare'
|
||||
import { pack, publish } from '@pnpm/plugin-commands-publishing'
|
||||
import { DEFAULT_OPTS } from './utils'
|
||||
import execa = require('execa')
|
||||
import path = require('path')
|
||||
import crossSpawn = require('cross-spawn')
|
||||
import fs = require('mz/fs')
|
||||
@@ -599,3 +600,25 @@ test('publish: ignores all the lifecycle scripts when --ignore-scripts is used',
|
||||
expect(await exists('package.json')).toBeTruthy()
|
||||
expect(await exists('output.json')).toBeFalsy()
|
||||
})
|
||||
|
||||
test('publish: with specified publish branch name', async () => {
|
||||
prepare({
|
||||
name: 'test-publish-package.json',
|
||||
version: '0.0.2',
|
||||
})
|
||||
|
||||
const branch = 'some-random-publish-branch'
|
||||
await execa('git', ['init'])
|
||||
await execa('git', ['checkout', '-b', branch])
|
||||
await execa('git', ['config', 'user.email', 'x@y.z'])
|
||||
await execa('git', ['config', 'user.name', 'xyz'])
|
||||
await execa('git', ['add', '*'])
|
||||
await execa('git', ['commit', '-m', 'init', '--no-gpg-sign'])
|
||||
|
||||
await publish.handler({
|
||||
...DEFAULT_OPTS,
|
||||
argv: { original: ['publish', '--publish-branch', branch, ...CREDENTIALS] },
|
||||
dir: process.cwd(),
|
||||
publishBranch: branch,
|
||||
}, [])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user