Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

child_process: align fork/spawn stdio error msg #11044

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 9 additions & 10 deletions lib/child_process.js
Expand Up @@ -18,7 +18,14 @@ const setupChannel = child_process.setupChannel;
const ChildProcess = exports.ChildProcess = child_process.ChildProcess;

function stdioStringToArray(option) {
return [option, option, option, 'ipc'];
switch (option) {
case 'ignore':
case 'pipe':
case 'inherit':
return [option, option, option, 'ipc'];
default:
throw new TypeError('Incorrect value of stdio option: ' + option);
}
}

exports.fork = function(modulePath /*, args, options*/) {
Expand Down Expand Up @@ -55,15 +62,7 @@ exports.fork = function(modulePath /*, args, options*/) {
args = execArgv.concat([modulePath], args);

if (typeof options.stdio === 'string') {
switch (options.stdio) {
case 'ignore':
case 'pipe':
case 'inherit':
options.stdio = stdioStringToArray(options.stdio);
break;
default:
throw new TypeError('Unknown stdio option');
}
options.stdio = stdioStringToArray(options.stdio);
} else if (!Array.isArray(options.stdio)) {
// Use a separate fd=3 for the IPC channel. Inherit stdin, stdout,
// and stderr from the parent if silent isn't set.
Expand Down
Expand Up @@ -9,7 +9,7 @@ const assert = require('assert');
const fork = require('child_process').fork;

const childScript = `${common.fixturesDir}/child-process-spawn-node`;
const errorRegexp = /^TypeError: Unknown stdio option$/;
const errorRegexp = /^TypeError: Incorrect value of stdio option:/;
const malFormedOpts = {stdio: '33'};
const payload = {hello: 'world'};
const stringOpts = {stdio: 'pipe'};
Expand Down