Skip to content

Commit 3b94e31

Browse files
author
Myles Borins
committed
test: robust handling of env for npm-test-install
Currently we are overwriting the entire env object of the child-process spawned in `npm-test-install`. This commit alternatively clones the `process.env` object and modifies it with the neccessary changes before passing it the the spawned process. Fixes: #6736 PR-URL: #6797 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 6a76485 commit 3b94e31

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

test/parallel/test-npm-install.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ const pkgPath = path.join(common.tmpDir, 'package.json');
3232

3333
fs.writeFileSync(pkgPath, pkgContent);
3434

35+
const env = Object.create(process.env);
36+
env['PATH'] = path.dirname(process.execPath);
37+
3538
const proc = spawn(process.execPath, args, {
3639
cwd: common.tmpDir,
37-
env: {
38-
PATH: path.dirname(process.execPath)
39-
}
40+
env: env
4041
});
4142

4243
function handleExit(code, signalCode) {

0 commit comments

Comments
 (0)