Skip to content

fix: pass script-shell to publish lifecycle hooks#9492

Merged
owlstronaut merged 1 commit into
npm:latestfrom
Zelys-DFKH:fix/publish-script-shell
Jun 5, 2026
Merged

fix: pass script-shell to publish lifecycle hooks#9492
owlstronaut merged 1 commit into
npm:latestfrom
Zelys-DFKH:fix/publish-script-shell

Conversation

@Zelys-DFKH
Copy link
Copy Markdown
Contributor

@Zelys-DFKH Zelys-DFKH commented Jun 4, 2026

npm run passes script-shell to @npmcli/run-script, but the three runScript() calls in publish.js for prepublishOnly, publish, and postpublish never did. On Windows, where users set script-shell to bash in .npmrc, lifecycle hooks still ran under cmd.exe, while explicit npm run calls used the configured shell. The fix reads script-shell from config in #publish() and passes it to all three calls, matching the pattern in run.js.

Fixes #9477
Credit: @wiggisser's analysis in #9477.

npm run passes script-shell to @npmcli/run-script, but the three
runScript() calls in publish.js for prepublishOnly, publish, and
postpublish never did. On Windows, where users set script-shell to
bash in .npmrc, those lifecycle hooks still ran under cmd.exe while
explicit npm run calls used the configured shell.

Reads script-shell from config in #publish() and passes it to all
three calls, matching the existing pattern in run.js. Adds script-shell
to static params so it appears in npm help publish.

Fixes npm#9477
@Zelys-DFKH Zelys-DFKH requested review from a team as code owners June 4, 2026 18:56
@owlstronaut owlstronaut merged commit 0e55f97 into npm:latest Jun 5, 2026
23 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

🎉 Backport to release/v11 created: #9499

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] script-shell setting not respected in prepublishOnly

2 participants