Conversation
`npm install-scripts approve <pkg> --dry-run` and `deny <pkg> --dry-run` wrote the `allowScripts` entry to package.json instead of previewing it, and printed the summary in the past tense, worded identically to a real run. The same applied to `--all`. `writePolicyChanges()` never read the flag. Its sibling `runPrune()` does: it reads `dry-run`, skips the save, and reports "Would remove ..." rather than "Removed ...". Read the flag in the shared writer too, skip `pkg.save()` when it is set, and pick the conditional wording so the summary describes what actually happened. The `--json` summary now carries a `dryRun` key, mirroring the prune summary, so machine consumers can tell a preview from an applied change. Co-Authored-By: pi 0.85.1 (deepseek-v4-flash) <noreply@earendil.works>
Rocin1738
reviewed
Sep 18, 2026
Rocin1738
left a comment
There was a problem hiding this comment.
I meant to say I take for responsibility there's no excuses so don't matter once again thank you I appreciate you guys for giving me a chance
| printSummary (summary) { | ||
| printSummary (summary, { dryRun }) { | ||
| if (this.npm.flatOptions.json) { | ||
| output.buffer({ allowScripts: summary }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #9992.
npm install-scripts approve <pkg> --dry-runanddeny <pkg> --dry-runwrote theallowScriptsentry topackage.jsonand printed the summary in the past tense, worded identically to a real run. Both flags are documented for the command, so a preview was performing the write and giving no sign it had.The sibling
prunesubcommand already gets this right, which is what made the gap look like an oversight rather than a design choice:writePolicyChanges()never read the flag;runPrune()does. This reads it in the same place, skipspkg.save()when it is set, and selects the conditional wording so the summary describes what actually happened.Changes
lib/utils/allow-scripts-cmd.js: readdry-runinwritePolicyChanges(), guard the save, pass the flag toprintSummary(), and let the summary chooseWould approve/Would denyover the past tense. The--jsonpayload gains adryRunkey, mirroring the prune JSON so machine consumers can distinguish a preview from an applied change.test/lib/commands/install-scripts.js: four tests coveringapprove <pkg>,approve --all,approve --jsonanddeny <pkg>under--dry-run.Testing
Before the fix the four new tests fail (4 of 27 in that file). After it,
test/lib/commands/install-scripts.jspasses 27/27 and the full suite passes 123/123 files:Coverage for the modified file is 100% statements, branches, functions and lines:
End to end, against the same reproduction as the issue:
The standalone
approve-scripts/deny-scriptsaliases share this code path and now honor the flag as well.