Skip to content

Commit

Permalink
child_process: do not ignore proto values of env
Browse files Browse the repository at this point in the history
This reverts this behaviour introduced in a recent PR, and updates
the test. Without this change, CitGM and other packages are broken.

PR-URL: #18210
Fixes: nodejs/citgm#536
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
apapirovski committed Jan 18, 2018
1 parent 359a232 commit 38ee25e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`));
Expand Down

0 comments on commit 38ee25e

Please sign in to comment.