mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-12 01:54:53 -04:00
fix: publishConfig.directory script (#3497)
Co-authored-by: Zoltan Kochan <z@kochan.io>
This commit is contained in:
5
.changeset/tricky-yaks-fly.md
Normal file
5
.changeset/tricky-yaks-fly.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-publishing": patch
|
||||
---
|
||||
|
||||
fix publishConfig.directory script
|
||||
@@ -147,7 +147,8 @@ Do you want to continue?`,
|
||||
runNpm(opts.npmPath, ['publish', ...params])
|
||||
return
|
||||
}
|
||||
const dir = (params.length > 0) && params[0] || process.cwd()
|
||||
const dirInParams = (params.length > 0) && params[0]
|
||||
const dir = dirInParams || opts.dir || process.cwd()
|
||||
|
||||
const _runScriptsIfPresent = runScriptsIfPresent.bind(null, {
|
||||
depPath: dir,
|
||||
@@ -176,7 +177,10 @@ Do you want to continue?`,
|
||||
workspaceDir: opts.workspaceDir ?? dir,
|
||||
},
|
||||
async () => {
|
||||
const args = opts.argv.original.slice(1)
|
||||
let args = opts.argv.original.slice(1)
|
||||
if (dirInParams) {
|
||||
args = args.filter(arg => arg !== params[0])
|
||||
}
|
||||
const index = args.indexOf('--publish-branch')
|
||||
if (index !== -1) {
|
||||
// If --publish-branch follows with another cli option, only remove this argument
|
||||
@@ -188,7 +192,7 @@ Do you want to continue?`,
|
||||
}
|
||||
}
|
||||
|
||||
const cwd = manifest.publishConfig?.directory ? path.join(dir, manifest.publishConfig.directory) : undefined
|
||||
const cwd = manifest.publishConfig?.directory ? path.join(dir, manifest.publishConfig.directory) : dir
|
||||
|
||||
const { status } = runNpm(opts.npmPath, ['publish', '--ignore-scripts', ...args], {
|
||||
cwd,
|
||||
|
||||
@@ -102,10 +102,10 @@ export default async function (
|
||||
const pkg = opts.selectedProjectsGraph[pkgDir].package
|
||||
const publishResult = await publish({
|
||||
...opts,
|
||||
dir: pkg.dir,
|
||||
argv: {
|
||||
original: [
|
||||
'publish',
|
||||
pkg.dir,
|
||||
'--tag',
|
||||
tag,
|
||||
'--registry',
|
||||
|
||||
@@ -67,7 +67,8 @@ test('recursive publish', async () => {
|
||||
},
|
||||
])
|
||||
|
||||
await fs.writeFile('.npmrc', CREDENTIALS, 'utf8')
|
||||
await fs.writeFile(path.join(pkg1.name, '.npmrc'), CREDENTIALS, 'utf8')
|
||||
await fs.writeFile(path.join(pkg2.name, '.npmrc'), CREDENTIALS, 'utf8')
|
||||
|
||||
await publish.handler({
|
||||
...DEFAULT_OPTS,
|
||||
@@ -249,7 +250,8 @@ test('recursive publish writes publish summary', async () => {
|
||||
},
|
||||
])
|
||||
|
||||
await fs.writeFile('.npmrc', CREDENTIALS, 'utf8')
|
||||
await fs.writeFile('@pnpmtest/test-recursive-publish-project-3/.npmrc', CREDENTIALS, 'utf8')
|
||||
await fs.writeFile('@pnpmtest/test-recursive-publish-project-4/.npmrc', CREDENTIALS, 'utf8')
|
||||
|
||||
process.env.npm_config_userconfig = path.join('.npmrc')
|
||||
await publish.handler({
|
||||
|
||||
Reference in New Issue
Block a user