test: properly extend process.env in child_process

PR-URL: https://github.com/nodejs/node/pull/22430
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: George Adams <george.adams@uk.ibm.com>
This commit is contained in:
Lucas Woo authored and Michaël Zasso committed 2018-09-06 08:52:21 +02:00
1 parent 8d02fc64dc
commit 2d8e6374bc
1 file changed
+4 -6
+4 -6
View File
@@ -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 });
}