From 56ae651c802504127a6361d56319afa8e6911d8f Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Mon, 16 May 2016 17:23:53 -0700 Subject: [PATCH] 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: https://github.com/nodejs/node/issues/6736 PR-URL: https://github.com/nodejs/node/pull/6797 Reviewed-By: Michael Dawson Reviewed-By: James M Snell --- test/parallel/test-npm-install.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-npm-install.js b/test/parallel/test-npm-install.js index b6ef67bf322ea3..c716e48aefedab 100644 --- a/test/parallel/test-npm-install.js +++ b/test/parallel/test-npm-install.js @@ -32,11 +32,12 @@ const pkgPath = path.join(common.tmpDir, 'package.json'); fs.writeFileSync(pkgPath, pkgContent); +const env = Object.create(process.env); +env['PATH'] = path.dirname(process.execPath); + const proc = spawn(process.execPath, args, { cwd: common.tmpDir, - env: { - PATH: path.dirname(process.execPath) - } + env: env }); function handleExit(code, signalCode) {