Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
Draft proposal for the Windows side of CLI-170 (#15347).
When
npx <package>infers an executable from packagebinmetadata, the executable name becomes part of a synthetic npm script. On Windows, that script is ultimately interpreted bycmd.exe. This change protects the inferred executable token according to the selected shell instead of forwarding it unquoted.Supporting dependency PR: npm/promise-spawn#166
Changes
lib/run-script.jscallscript was supplied.scriptShell, including POSIX shells selected on Windows.cmd.exe, protect command separators, spaces, command keywords, and other cmd metacharacters.callas an intentionally supplied shell script; its arguments are not treated as inferred executable names.lib/index.jsThis cache-manifest adjustment is related hardening and may be split into a separate change during review if preferred.
Tests and documentation
Dependency requirement
The npm CLI change depends on the promise-spawn fix in npm/promise-spawn#166. That change allows promise-spawn to recognize an executable token that has already been quoted and caret-escaped, preserving
.cmd/.batdouble escaping for arguments.The dependency should be consumed through released
@npmcli/promise-spawnand@npmcli/run-scriptversions before merging this PR. The tracked bundled promise-spawn copy is included here to show the integrated behavior and should be regenerated from the released dependency during final dependency updates.Validation
git diff --checkpasses.Review status
This is intentionally a draft while the promise-spawn dependency change and release sequence are reviewed.