mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
PR-URL: https://github.com/nodejs/node/pull/14845 Backport-PR-URL: https://github.com/nodejs/node/pull/15557 Fixes: https://github.com/nodejs/node/issues/14823 Refs: https://github.com/nodejs/node/pull/14822 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
38 lines
805 B
JavaScript
38 lines
805 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
const spawn = require('child_process').spawn;
|
|
|
|
const env = {
|
|
'HELLO': 'WORLD'
|
|
};
|
|
Object.setPrototypeOf(env, {
|
|
'FOO': 'BAR'
|
|
});
|
|
|
|
let child;
|
|
if (common.isWindows) {
|
|
child = spawn('cmd.exe', ['/c', 'set'],
|
|
Object.assign({}, process.env, { env: env }));
|
|
} else {
|
|
child = spawn('/usr/bin/env', [], { env: env });
|
|
child = spawn('/usr/bin/env', [],
|
|
Object.assign({}, process.env, { env: env }));
|
|
}
|
|
|
|
|
|
let response = '';
|
|
|
|
child.stdout.setEncoding('utf8');
|
|
|
|
child.stdout.on('data', function(chunk) {
|
|
console.log(`stdout: ${chunk}`);
|
|
response += chunk;
|
|
});
|
|
|
|
process.on('exit', function() {
|
|
assert.ok(response.includes('HELLO=WORLD'));
|
|
assert.ok(response.includes('FOO=BAR'));
|
|
});
|