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: https://github.com/nodejs/node/pull/18210
Fixes: https://github.com/nodejs/citgm/issues/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>
This commit is contained in:
Anatoli Papirovski 2018-01-17 13:30:43 -05:00
parent 359a232348
commit 38ee25e2e2
No known key found for this signature in database
GPG Key ID: 614E2E1ABEB4B2C0
2 changed files with 3 additions and 2 deletions

View File

@ -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}`);

View File

@ -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}`));