@@ -19,15 +19,20 @@ const ChildProcess = exports.ChildProcess = child_process.ChildProcess;
19
19
exports . fork = function ( modulePath /*, args, options*/ ) {
20
20
21
21
// Get options and args arguments.
22
- var options , args , execArgv ;
23
- if ( Array . isArray ( arguments [ 1 ] ) ) {
24
- args = arguments [ 1 ] ;
25
- options = util . _extend ( { } , arguments [ 2 ] ) ;
26
- } else if ( arguments [ 1 ] && typeof arguments [ 1 ] !== 'object' ) {
27
- throw new TypeError ( 'Incorrect value of args option' ) ;
28
- } else {
29
- args = [ ] ;
30
- options = util . _extend ( { } , arguments [ 1 ] ) ;
22
+ var execArgv ;
23
+ var options = { } ;
24
+ var args = [ ] ;
25
+ var pos = 1 ;
26
+ if ( Array . isArray ( arguments [ pos ] ) ) {
27
+ args = arguments [ pos ++ ] ;
28
+ }
29
+
30
+ if ( arguments [ pos ] != null ) {
31
+ if ( typeof arguments [ pos ] !== 'object' ) {
32
+ throw new TypeError ( 'Incorrect value of args option' ) ;
33
+ } else {
34
+ options = util . _extend ( { } , arguments [ pos ++ ] ) ;
35
+ }
31
36
}
32
37
33
38
// Prepare arguments for fork:
@@ -132,7 +137,7 @@ exports.execFile = function(file /*, args, options, callback*/) {
132
137
callback = arguments [ pos ++ ] ;
133
138
}
134
139
135
- if ( pos === 1 && arguments . length > 1 ) {
140
+ if ( ! callback && arguments [ pos ] != null ) {
136
141
throw new TypeError ( 'Incorrect value of args option' ) ;
137
142
}
138
143
0 commit comments