| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e8dbd09 commit 22b4149
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,6 +65,11 @@ exports.fork = function(modulePath /*, args, options*/) { | |||
| 65 | 65 | args = arguments[pos++]; | |
| 66 | 66 | } | |
| 67 | 67 | ||
| 68 | + if (pos < arguments.length && | ||
| 69 | + (arguments[pos] === undefined || arguments[pos] === null)) { | ||
| 70 | + pos++; | ||
| 71 | + } | ||
| 72 | + | ||
| 68 | 73 | if (pos < arguments.length && arguments[pos] != null) { | |
| 69 | 74 | if (typeof arguments[pos] !== 'object') { | |
| 70 | 75 | throw new TypeError('Incorrect value of args option'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + process.send({ env: process.env }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,37 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const fixtures = require('../common/fixtures'); | ||
| 4 | + | ||
| 5 | + // This test ensures that fork should parse options | ||
| 6 | + // correctly if args is undefined or null | ||
| 7 | + | ||
| 8 | + const assert = require('assert'); | ||
| 9 | + const { fork } = require('child_process'); | ||
| 10 | + | ||
| 11 | + const expectedEnv = { foo: 'bar' }; | ||
| 12 | + | ||
| 13 | + { | ||
| 14 | + const cp = fork(fixtures.path('child-process-echo-options.js'), undefined, | ||
| 15 | + { env: Object.assign({}, process.env, expectedEnv) }); | ||
| 16 | + | ||
| 17 | + cp.on('message', common.mustCall(({ env }) => { | ||
| 18 | + assert.strictEqual(env.foo, expectedEnv.foo); | ||
| 19 | + })); | ||
| 20 | + | ||
| 21 | + cp.on('exit', common.mustCall((code) => { | ||
| 22 | + assert.strictEqual(code, 0); | ||
| 23 | + })); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + { | ||
| 27 | + const cp = fork(fixtures.path('child-process-echo-options.js'), null, | ||
| 28 | + { env: Object.assign({}, process.env, expectedEnv) }); | ||
| 29 | + | ||
| 30 | + cp.on('message', common.mustCall(({ env }) => { | ||
| 31 | + assert.strictEqual(env.foo, expectedEnv.foo); | ||
| 32 | + })); | ||
| 33 | + | ||
| 34 | + cp.on('exit', common.mustCall((code) => { | ||
| 35 | + assert.strictEqual(code, 0); | ||
| 36 | + })); | ||
| 37 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments