Skip to content

Commit 38ee25e

Browse files
committed
child_process: do not ignore proto values of env
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 359a232 commit 38ee25e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/child_process.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,8 @@ function normalizeSpawnArguments(file, args, options) {
504504
var env = options.env || process.env;
505505
var envPairs = [];
506506

507-
for (const key of Object.keys(env)) {
507+
// Prototype values are intentionally included.
508+
for (var key in env) {
508509
const value = env[key];
509510
if (value !== undefined) {
510511
envPairs.push(`${key}=${value}`);

test/parallel/test-child-process-env.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ child.stdout.on('data', function(chunk) {
5757

5858
process.on('exit', function() {
5959
assert.ok(response.includes('HELLO=WORLD'));
60-
assert.ok(!response.includes('FOO='));
60+
assert.ok(response.includes('FOO=BAR'));
6161
assert.ok(!response.includes('UNDEFINED=undefined'));
6262
assert.ok(response.includes('NULL=null'));
6363
assert.ok(response.includes(`EMPTY=${os.EOL}`));

0 commit comments

Comments
 (0)