fix(publish): respect --force flag in recursive publish (#10277)

When using 'pnpm -r publish --force', the --force flag was being
ignored. The flag was checked to determine which packages to publish,
but wasn't passed to individual publish commands.

This adds --force to the appendedArgs array so it gets passed through
to each publish call, following the same pattern as other CLI flags
like --access, --dry-run, and --otp.

close #10272
This commit is contained in:
Aaron
2025-12-08 11:33:30 +01:00
committed by GitHub
parent 19f36cfc39
commit fea46dc8c4
2 changed files with 9 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/plugin-commands-publishing": patch
"pnpm": patch
---
`pnpm publish -r --force` should allow to run publish over already existing versions in the registry [#10272](https://github.com/pnpm/pnpm/issues/10272).

View File

@@ -99,6 +99,9 @@ export async function recursivePublish (
if (opts.dryRun) {
appendedArgs.push('--dry-run')
}
if (opts.force) {
appendedArgs.push('--force')
}
if (opts.cliOptions['otp']) {
appendedArgs.push(`--otp=${opts.cliOptions['otp'] as string}`)
}