File tree 3 files changed +19
-3
lines changed
3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -391,6 +391,11 @@ controller.abort();
391
391
<!-- YAML
392
392
added: v0.5.0
393
393
changes:
394
+ - version:
395
+ - REPLACEME
396
+ pr-url: https://github.com/nodejs/node/pull/41225
397
+ description: The `modulePath` parameter can be a WHATWG `URL` object using
398
+ `file:` protocol.
394
399
- version:
395
400
- v16.4.0
396
401
- v14.18.0
@@ -425,7 +430,7 @@ changes:
425
430
description: The `stdio` option is supported now.
426
431
-->
427
432
428
- * ` modulePath ` {string} The module to run in the child.
433
+ * ` modulePath ` {string|URL } The module to run in the child.
429
434
* ` args ` {string\[ ] } List of string arguments.
430
435
* ` options ` {Object}
431
436
* ` cwd ` {string|URL} Current working directory of the child process.
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ const MAX_BUFFER = 1024 * 1024;
91
91
92
92
/**
93
93
* Spawns a new Node.js process + fork.
94
- * @param {string } modulePath
94
+ * @param {string|URL } modulePath
95
95
* @param {string[] } [args]
96
96
* @param {{
97
97
* cwd?: string;
@@ -112,7 +112,7 @@ const MAX_BUFFER = 1024 * 1024;
112
112
* @returns {ChildProcess }
113
113
*/
114
114
function fork ( modulePath /* , args, options */ ) {
115
- validateString ( modulePath , 'modulePath' ) ;
115
+ modulePath = getValidatedPath ( modulePath , 'modulePath' ) ;
116
116
117
117
// Get options and args arguments.
118
118
let execArgv ;
Original file line number Diff line number Diff line change
1
+ import { mustCall } from '../common/index.mjs' ;
2
+ import { fork } from 'child_process' ;
3
+
4
+ if ( process . argv [ 2 ] === 'child' ) {
5
+ process . disconnect ( ) ;
6
+ } else {
7
+ const child = fork ( new URL ( import . meta. url ) , [ 'child' ] ) ;
8
+
9
+ child . on ( 'disconnect' , mustCall ( ) ) ;
10
+ child . once ( 'exit' , mustCall ( ) ) ;
11
+ }
You can’t perform that action at this time.
0 commit comments