Skip to content

Commit

Permalink
test: properly extend process.env in child_process
Browse files Browse the repository at this point in the history
PR-URL: #22430
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: George Adams <[email protected]>
  • Loading branch information
legendecas authored and targos committed Sep 3, 2018
1 parent f8feb02 commit d27e463
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions test/parallel/test-child-process-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,21 @@ const os = require('os');

const spawn = require('child_process').spawn;

const env = {
const env = Object.assign({}, process.env, {
'HELLO': 'WORLD',
'UNDEFINED': undefined,
'NULL': null,
'EMPTY': ''
};
});
Object.setPrototypeOf(env, {
'FOO': 'BAR'
});

let child;
if (common.isWindows) {
child = spawn('cmd.exe', ['/c', 'set'],
Object.assign({}, process.env, { env }));
child = spawn('cmd.exe', ['/c', 'set'], { env });
} else {
child = spawn('/usr/bin/env', [],
Object.assign({}, process.env, { env }));
child = spawn('/usr/bin/env', [], { env });
}


Expand Down

0 comments on commit d27e463

Please sign in to comment.