From 38ee25e2e205270c6ff258742aa34b442d9bc580 Mon Sep 17 00:00:00 2001 From: Anatoli Papirovski Date: Wed, 17 Jan 2018 13:30:43 -0500 Subject: [PATCH] child_process: do not ignore proto values of env MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts this behaviour introduced in a recent PR, and updates the test. Without this change, CitGM and other packages are broken. PR-URL: https://github.com/nodejs/node/pull/18210 Fixes: https://github.com/nodejs/citgm/issues/536 Reviewed-By: Evan Lucas Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Matteo Collina Reviewed-By: Michaƫl Zasso --- lib/child_process.js | 3 ++- test/parallel/test-child-process-env.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/child_process.js b/lib/child_process.js index f2c1a0c237b..00d1bfc57de 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -504,7 +504,8 @@ function normalizeSpawnArguments(file, args, options) { var env = options.env || process.env; var envPairs = []; - for (const key of Object.keys(env)) { + // Prototype values are intentionally included. + for (var key in env) { const value = env[key]; if (value !== undefined) { envPairs.push(`${key}=${value}`); diff --git a/test/parallel/test-child-process-env.js b/test/parallel/test-child-process-env.js index 2437e203310..a819c5a64ee 100644 --- a/test/parallel/test-child-process-env.js +++ b/test/parallel/test-child-process-env.js @@ -57,7 +57,7 @@ child.stdout.on('data', function(chunk) { process.on('exit', function() { assert.ok(response.includes('HELLO=WORLD')); - assert.ok(!response.includes('FOO=')); + assert.ok(response.includes('FOO=BAR')); assert.ok(!response.includes('UNDEFINED=undefined')); assert.ok(response.includes('NULL=null')); assert.ok(response.includes(`EMPTY=${os.EOL}`));