@@ -37,7 +37,6 @@ const {
37
37
ERR_CHILD_PROCESS_IPC_REQUIRED ,
38
38
ERR_CHILD_PROCESS_STDIO_MAXBUFFER ,
39
39
ERR_INVALID_ARG_TYPE ,
40
- ERR_INVALID_OPT_VALUE ,
41
40
ERR_OUT_OF_RANGE
42
41
} = require ( 'internal/errors' ) . codes ;
43
42
const { clearTimeout, setTimeout } = require ( 'timers' ) ;
@@ -46,24 +45,14 @@ const child_process = require('internal/child_process');
46
45
const {
47
46
getValidStdio,
48
47
setupChannel,
49
- ChildProcess
48
+ ChildProcess,
49
+ stdioStringToArray
50
50
} = child_process ;
51
51
52
52
const MAX_BUFFER = 1024 * 1024 ;
53
53
54
54
exports . ChildProcess = ChildProcess ;
55
55
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
-
67
56
exports . fork = function fork ( modulePath /* , args, options */ ) {
68
57
validateString ( modulePath , 'modulePath' ) ;
69
58
@@ -104,12 +93,13 @@ exports.fork = function fork(modulePath /* , args, options */) {
104
93
args = execArgv . concat ( [ modulePath ] , args ) ;
105
94
106
95
if ( typeof options . stdio === 'string' ) {
107
- options . stdio = stdioStringToArray ( options . stdio ) ;
96
+ options . stdio = stdioStringToArray ( options . stdio , 'ipc' ) ;
108
97
} else if ( ! Array . isArray ( options . stdio ) ) {
109
98
// Use a separate fd=3 for the IPC channel. Inherit stdin, stdout,
110
99
// 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' ) ;
113
103
} else if ( ! options . stdio . includes ( 'ipc' ) ) {
114
104
throw new ERR_CHILD_PROCESS_IPC_REQUIRED ( 'options.stdio' ) ;
115
105
}
0 commit comments