@@ -37,7 +37,6 @@ const {
3737 ERR_CHILD_PROCESS_IPC_REQUIRED ,
3838 ERR_CHILD_PROCESS_STDIO_MAXBUFFER ,
3939 ERR_INVALID_ARG_TYPE ,
40- ERR_INVALID_OPT_VALUE ,
4140 ERR_OUT_OF_RANGE
4241} = require ( 'internal/errors' ) . codes ;
4342const { clearTimeout, setTimeout } = require ( 'timers' ) ;
@@ -46,24 +45,14 @@ const child_process = require('internal/child_process');
4645const {
4746 getValidStdio,
4847 setupChannel,
49- ChildProcess
48+ ChildProcess,
49+ stdioStringToArray
5050} = child_process ;
5151
5252const MAX_BUFFER = 1024 * 1024 ;
5353
5454exports . ChildProcess = ChildProcess ;
5555
56- function stdioStringToArray ( option ) {
57- switch ( option ) {
58- case 'ignore' :
59- case 'pipe' :
60- case 'inherit' :
61- return [ option , option , option , 'ipc' ] ;
62- default :
63- throw new ERR_INVALID_OPT_VALUE ( 'stdio' , option ) ;
64- }
65- }
66-
6756exports . fork = function fork ( modulePath /* , args, options */ ) {
6857 validateString ( modulePath , 'modulePath' ) ;
6958
@@ -104,12 +93,13 @@ exports.fork = function fork(modulePath /* , args, options */) {
10493 args = execArgv . concat ( [ modulePath ] , args ) ;
10594
10695 if ( typeof options . stdio === 'string' ) {
107- options . stdio = stdioStringToArray ( options . stdio ) ;
96+ options . stdio = stdioStringToArray ( options . stdio , 'ipc' ) ;
10897 } else if ( ! Array . isArray ( options . stdio ) ) {
10998 // Use a separate fd=3 for the IPC channel. Inherit stdin, stdout,
11099 // and stderr from the parent if silent isn't set.
111- options . stdio = options . silent ? stdioStringToArray ( 'pipe' ) :
112- stdioStringToArray ( 'inherit' ) ;
100+ options . stdio = stdioStringToArray (
101+ options . silent ? 'pipe' : 'inherit' ,
102+ 'ipc' ) ;
113103 } else if ( ! options . stdio . includes ( 'ipc' ) ) {
114104 throw new ERR_CHILD_PROCESS_IPC_REQUIRED ( 'options.stdio' ) ;
115105 }
0 commit comments