Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit 6464e70

Browse files
committed
meta: merge node/master into node-chakracore/master
Merge 85739b6 as of 2018-01-15 This commit was automatically generated. For any problems, please contact jackhorton Reviewed-By: Jack Horton <[email protected]>
2 parents e32462b + 85739b6 commit 6464e70

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Diff for: doc/api/child_process.md

+2
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ If not given, the default is to inherit the current working directory.
437437
Use `env` to specify environment variables that will be visible to the new
438438
process, the default is [`process.env`][].
439439

440+
`undefined` values in `env` will be ignored.
441+
440442
Example of running `ls -lh /usr`, capturing `stdout`, `stderr`, and the
441443
exit code:
442444

Diff for: lib/child_process.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,11 @@ function normalizeSpawnArguments(file, args, options) {
504504
var env = options.env || process.env;
505505
var envPairs = [];
506506

507-
for (var key in env) {
508-
envPairs.push(`${key}=${env[key]}`);
507+
for (const key of Object.keys(env)) {
508+
const value = env[key];
509+
if (value !== undefined) {
510+
envPairs.push(`${key}=${value}`);
511+
}
509512
}
510513

511514
_convertCustomFds(options);

Diff for: test/parallel/test-child-process-env.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@
2222
'use strict';
2323
const common = require('../common');
2424
const assert = require('assert');
25+
const os = require('os');
2526

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

2829
const env = {
29-
'HELLO': 'WORLD'
30+
'HELLO': 'WORLD',
31+
'UNDEFINED': undefined,
32+
'NULL': null,
33+
'EMPTY': ''
3034
};
3135
Object.setPrototypeOf(env, {
3236
'FOO': 'BAR'
@@ -53,5 +57,8 @@ child.stdout.on('data', function(chunk) {
5357

5458
process.on('exit', function() {
5559
assert.ok(response.includes('HELLO=WORLD'));
56-
assert.ok(response.includes('FOO=BAR'));
60+
assert.ok(!response.includes('FOO='));
61+
assert.ok(!response.includes('UNDEFINED=undefined'));
62+
assert.ok(response.includes('NULL=null'));
63+
assert.ok(response.includes(`EMPTY=${os.EOL}`));
5764
});

0 commit comments

Comments
 (0)