child_process: add support for URL to cp.fork
PR-URL: https://github.com/nodejs/node/pull/41225 Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
23637e9a3b
commit
81812bad7b
@ -391,6 +391,11 @@ controller.abort();
|
|||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v0.5.0
|
added: v0.5.0
|
||||||
changes:
|
changes:
|
||||||
|
- version:
|
||||||
|
- REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/41225
|
||||||
|
description: The `modulePath` parameter can be a WHATWG `URL` object using
|
||||||
|
`file:` protocol.
|
||||||
- version:
|
- version:
|
||||||
- v16.4.0
|
- v16.4.0
|
||||||
- v14.18.0
|
- v14.18.0
|
||||||
@ -425,7 +430,7 @@ changes:
|
|||||||
description: The `stdio` option is supported now.
|
description: The `stdio` option is supported now.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
* `modulePath` {string} The module to run in the child.
|
* `modulePath` {string|URL} The module to run in the child.
|
||||||
* `args` {string\[]} List of string arguments.
|
* `args` {string\[]} List of string arguments.
|
||||||
* `options` {Object}
|
* `options` {Object}
|
||||||
* `cwd` {string|URL} Current working directory of the child process.
|
* `cwd` {string|URL} Current working directory of the child process.
|
||||||
|
@ -91,7 +91,7 @@ const MAX_BUFFER = 1024 * 1024;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Spawns a new Node.js process + fork.
|
* Spawns a new Node.js process + fork.
|
||||||
* @param {string} modulePath
|
* @param {string|URL} modulePath
|
||||||
* @param {string[]} [args]
|
* @param {string[]} [args]
|
||||||
* @param {{
|
* @param {{
|
||||||
* cwd?: string;
|
* cwd?: string;
|
||||||
@ -112,7 +112,7 @@ const MAX_BUFFER = 1024 * 1024;
|
|||||||
* @returns {ChildProcess}
|
* @returns {ChildProcess}
|
||||||
*/
|
*/
|
||||||
function fork(modulePath /* , args, options */) {
|
function fork(modulePath /* , args, options */) {
|
||||||
validateString(modulePath, 'modulePath');
|
modulePath = getValidatedPath(modulePath, 'modulePath');
|
||||||
|
|
||||||
// Get options and args arguments.
|
// Get options and args arguments.
|
||||||
let execArgv;
|
let execArgv;
|
||||||
|
11
test/parallel/test-child-process-fork-url.mjs
Normal file
11
test/parallel/test-child-process-fork-url.mjs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { mustCall } from '../common/index.mjs';
|
||||||
|
import { fork } from 'child_process';
|
||||||
|
|
||||||
|
if (process.argv[2] === 'child') {
|
||||||
|
process.disconnect();
|
||||||
|
} else {
|
||||||
|
const child = fork(new URL(import.meta.url), ['child']);
|
||||||
|
|
||||||
|
child.on('disconnect', mustCall());
|
||||||
|
child.once('exit', mustCall());
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user