-
-
Notifications
You must be signed in to change notification settings - Fork 156
win: fix spawning npm #635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixes spawning NPM under Windows. Fixes: nodejs#634
Codecov Report
@@ Coverage Diff @@
## master #635 +/- ##
==========================================
- Coverage 95.46% 95.24% -0.22%
==========================================
Files 26 26
Lines 816 821 +5
==========================================
+ Hits 779 782 +3
- Misses 37 39 +2
Continue to review full report at Codecov.
|
/cc @nodejs/citgm |
if (context.options.testPath) { | ||
options.env.PATH = `${context.options.testPath}:${process.env.PATH}`; | ||
nodeBin = which('node', { | ||
path: options.env.PATH || process.env.PATH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can options.env.PATH
ever not be process.env.PATH
outside of this if
? (i.e. does the nodeBin
calculation need to occur outside of the if
statement?)
The code being very similar to what we have in https://github.com/nodejs/citgm/blob/b3b60c38152925661362e2f725ca8e7e8e52ab0a/lib/package-manager/test.js, would it make sense to extract it to a common function? |
options.env.PATH = `${binDirectory}:${process.env.PATH}`; | ||
|
||
const proc = spawn(packageManagerBin, args, options); | ||
const proc = spawn(nodeBin, args, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this still work if the package manager is a script? Say I halve aliased npm
to some
#!/usr/bin/env bash
node /path/to/npm.js --log-level=silly $0
More real script - the recommended way of installing yarn on mac is through brew - and they use a script not a JS file. So node cannot execute the file. See #560 (comment)
There is an alternative fix already proposed here: 84b5048 |
Fixes spawning npm under Windows. CITGM would try to spawn
npm-cli.js
directly, causing Windows Script Host to get used to run the npm code.Fixes: #634
Checklist
npm test
passes (linter passes, tests are broken on Windows)