Add `ipc` option (#794)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent 7710440 · Browse files · 10 files·+154 added−146 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
10 files+154 added−146 removed
- tests:+97 added−87 removed
- other:+57 added−59 removed
Provenance
- Commit
c8a7961- Tree
53d17ca- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
7710440
10 files changed+154 added−146 removed
modified:lib/stdio/normalize.js+7 added-12 removed
123456745678910910111213141513 unmodified lines29303132323334353637import {STANDARD_STREAMS_ALIASES} from './utils.js';
// Add support for `stdin`/`stdout`/`stderr` as an alias for `stdio`export const normalizeStdio = options => { if (!options) { return [undefined, undefined, undefined]; }export const normalizeStdio = ({stdio, ipc, ...options}) => { const stdioArray = getStdioArray(stdio, options); return ipc && !stdioArray.includes('ipc') ? [...stdioArray, 'ipc'] : stdioArray;};
const {stdio} = options;
const getStdioArray = (stdio, options) => { if (stdio === undefined) { return STANDARD_STREAMS_ALIASES.map(alias => options[alias]); }
13 unmodified lines return Array.from({length}, (value, index) => stdio[index]);};
const hasAlias = options => STANDARD_STREAMS_ALIASES.some(alias => options[alias] !== undefined);
// Same but for `execaNode()`, i.e. push `ipc` unless already presentexport const normalizeStdioNode = options => { const stdio = normalizeStdio(options); return stdio.includes('ipc') ? stdio : [...stdio, 'ipc'];};modified:test/fixtures/send.js+2 added-6 removed
12345678945678#!/usr/bin/env nodeimport process from 'node:process';
process.on('message', message => { if (message === 'ping') { process.send('pong'); } else { throw new Error('Receive wrong message'); }process.once('message', message => { console.log(message);});
process.send('');modified:test/stdio/normalize.js+1 added-22 removed
123345679 unmodified lines171819202122232122232417 unmodified lines42434445495051525354555657585960616263646566import {inspect} from 'node:util';import test from 'ava';import {normalizeStdio, normalizeStdioNode} from '../../lib/stdio/normalize.js';import {normalizeStdio} from '../../lib/stdio/normalize.js';
const macro = (t, input, expected, func) => { if (expected instanceof Error) { t.throws(() => {9 unmodified lines
const stdioMacro = (...args) => macro(...args, normalizeStdio);stdioMacro.title = macroTitle('execa()');
test(stdioMacro, undefined, [undefined, undefined, undefined]);test(stdioMacro, null, [undefined, undefined, undefined]);
test(stdioMacro, {stdio: 'inherit'}, ['inherit', 'inherit', 'inherit']);test(stdioMacro, {stdio: 'pipe'}, ['pipe', 'pipe', 'pipe']);test(stdioMacro, {stdio: 'ignore'}, ['ignore', 'ignore', 'ignore']);test(stdioMacro, {stdio: [0, 1, 2]}, [0, 1, 2]);17 unmodified linestest(stdioMacro, {stdin: 'inherit', stdio: 'pipe'}, new Error('It\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`'));test(stdioMacro, {stdin: 'inherit', stdio: ['pipe']}, new Error('It\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`'));test(stdioMacro, {stdin: 'inherit', stdio: [undefined, 'pipe']}, new Error('It\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`'));test(stdioMacro, {stdin: 0, stdio: 'pipe'}, new Error('It\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`'));
const forkMacro = (...args) => macro(...args, normalizeStdioNode);forkMacro.title = macroTitle('execaNode()');
test(forkMacro, undefined, [undefined, undefined, undefined, 'ipc']);test(forkMacro, {stdio: 'ignore'}, ['ignore', 'ignore', 'ignore', 'ipc']);test(forkMacro, {stdio: 'ipc'}, ['ipc', 'ipc', 'ipc']);test(forkMacro, {stdio: [0, 1, 2]}, [0, 1, 2, 'ipc']);test(forkMacro, {stdio: [0, 1, 2, 3]}, [0, 1, 2, 3, 'ipc']);test(forkMacro, {stdio: [0, 1, 2, 'ipc']}, [0, 1, 2, 'ipc']);
test(forkMacro, {stdio: [0, 1, undefined]}, [0, 1, undefined, 'ipc']);test(forkMacro, {stdio: [0, 1, 2, undefined]}, [0, 1, 2, undefined, 'ipc']);test(forkMacro, {stdout: 'ignore'}, [undefined, 'ignore', undefined, 'ipc']);test(forkMacro, {stdout: 'ignore', stderr: 'ignore'}, [undefined, 'ignore', 'ignore', 'ipc']);
test(forkMacro, {stdio: {foo: 'bar'}}, new TypeError('Expected `stdio` to be of type `string` or `Array`, got `object`'));test(forkMacro, {stdin: 'inherit', stdio: 'pipe'}, new Error('It\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`'));modified:test/kill.js+2 added-2 removed
12 unmodified lines13 const TIMEOUT_REGEXP = /timed out after/;14 15 const spawnNoKillable = async (forceKillAfterDelay, options) => {16 const subprocess = execa('no-killable.js', {17- stdio: ['pipe', 'pipe', 'pipe', 'ipc'],17+ ipc: true,18 forceKillAfterDelay,19 ...options,20 });21 await pEvent(subprocess, 'message');230 unmodified lines252 test('spawnAndExit cleanup detached', spawnAndExit, true, true);253 254 // When parent process exits before child process255 const spawnAndKill = async (t, [signal, cleanup, detached, isKilled]) => {256- const subprocess = execa('sub-process.js', [cleanup, detached], {stdio: ['ignore', 'ignore', 'ignore', 'ipc']});256+ const subprocess = execa('sub-process.js', [cleanup, detached], {stdio: 'ignore', ipc: true});257 258 const pid = await pEvent(subprocess, 'message');259 t.true(Number.isInteger(pid));260 t.true(isRunning(pid));173 unmodified linesmodified:test/node.js+83 added-46 removed
1+import {dirname} from 'node:path';2 import process from 'node:process';3 import {pathToFileURL} from 'node:url';4 import test from 'ava';5+import getNode from 'get-node';6 import {pEvent} from 'p-event';5-import {execa, execaNode} from '../index.js';6-import {setFixtureDir, FIXTURES_DIR} from './helpers/fixtures-dir.js';7-import {fullStdio} from './helpers/stdio.js';7+import {execa, execaSync, execaNode} from '../index.js';8+import {FIXTURES_DIR} from './helpers/fixtures-dir.js';9+import {identity, fullStdio} from './helpers/stdio.js';10 import {foobarString} from './helpers/input.js';11 10-setFixtureDir();12+process.chdir(FIXTURES_DIR);13 12-test('node()', async t => {13- const {exitCode} = await execaNode('test/fixtures/noop.js');14+test('execaNode() succeeds', async t => {15+ const {exitCode} = await execaNode('noop.js');16 t.is(exitCode, 0);17 });18 17-test('node pipe stdout', async t => {18- const {stdout} = await execaNode('test/fixtures/noop.js', ['foo'], {19- stdout: 'pipe',20- });21-19+test('execaNode() returns stdout', async t => {20+ const {stdout} = await execaNode('noop.js', ['foo']);21 t.is(stdout, 'foo');22 });23 25-test('node does not return ipc channel\'s output', async t => {26- const {stdio} = await execaNode('test/fixtures/noop.js', ['foo']);27- t.deepEqual(stdio, [undefined, 'foo', '', undefined]);24+const getNodePath = async () => {25+ const {path} = await getNode(TEST_NODE_VERSION);26+ return path;27+};28+29+const TEST_NODE_VERSION = '16.0.0';30+31+const testNodePath = async (t, mapPath) => {32+ const nodePath = mapPath(await getNodePath());33+ const {stdout} = await execaNode('--version', {nodePath});34+ t.is(stdout, `v${TEST_NODE_VERSION}`);35+};36+37+test.serial('The "nodePath" option can be used', testNodePath, identity);38+test.serial('The "nodePath" option can be a file URL', testNodePath, pathToFileURL);39+40+test('The "nodePath" option defaults to the current Node.js binary', async t => {41+ const {stdout} = await execaNode('--version');42+ t.is(stdout, process.version);43 });44 30-test('node correctly use nodePath', async t => {31- const {stdout} = await execaNode(process.platform === 'win32' ? 'hello.cmd' : 'hello.sh', {32- stdout: 'pipe',33- nodePath: process.platform === 'win32' ? 'cmd.exe' : 'bash',34- nodeOptions: process.platform === 'win32' ? ['/c'] : [],35- });45+const nodePathArguments = ['node', ['-p', 'process.env.Path || process.env.PATH']];46 37- t.is(stdout, 'Hello World');47+const testExecPath = async (t, mapPath) => {48+ const execPath = mapPath(await getNodePath());49+ const {stdout} = await execa(...nodePathArguments, {preferLocal: true, execPath});50+ t.true(stdout.includes(TEST_NODE_VERSION));51+};52+53+test.serial('The "execPath" option can be used', testExecPath, identity);54+test.serial('The "execPath" option can be a file URL', testExecPath, pathToFileURL);55+56+test('The "execPath" option defaults to the current Node.js binary', async t => {57+ const {stdout} = await execa(...nodePathArguments, {preferLocal: true});58+ t.true(stdout.includes(dirname(process.execPath)));59 });60 40-test('The nodePath option can be a file URL', async t => {41- const nodePath = pathToFileURL(process.execPath);42- const {stdout} = await execaNode('test/fixtures/noop.js', ['foo'], {nodePath});43- t.is(stdout, 'foo');61+test.serial('The "execPath" option requires "preferLocal: true"', async t => {62+ const execPath = await getNodePath();63+ const {stdout} = await execa(...nodePathArguments, {execPath});64+ t.false(stdout.includes(TEST_NODE_VERSION));65 });66 46-test('node pass on nodeOptions', async t => {47- const {stdout} = await execaNode('console.log("foo")', {48- stdout: 'pipe',49- nodeOptions: ['-e'],50- });51-52- t.is(stdout, 'foo');67+test('The "nodeOptions" option can be used', async t => {68+ const {stdout} = await execaNode('empty.js', {nodeOptions: ['--version']});69+ t.is(stdout, process.version);70 });71 72 const spawnNestedExecaNode = (realExecArgv, fakeExecArgv, nodeOptions) => execa(73 'node',6 unmodified lines80 t.is(stdout, foobarString);81 t.is(stdio[3], '');82 };83 67-test('node removes --inspect without a port from nodeOptions when defined by parent process', testInspectRemoval, '--inspect');68-test('node removes --inspect with a port from nodeOptions when defined by parent process', testInspectRemoval, '--inspect=9222');69-test('node removes --inspect-brk without a port from nodeOptions when defined by parent process', testInspectRemoval, '--inspect-brk');70-test('node removes --inspect-brk with a port from nodeOptions when defined by parent process', testInspectRemoval, '--inspect-brk=9223');84+test('The "nodeOptions" option removes --inspect without a port when defined by parent process', testInspectRemoval, '--inspect');85+test('The "nodeOptions" option removes --inspect with a port when defined by parent process', testInspectRemoval, '--inspect=9222');86+test('The "nodeOptions" option removes --inspect-brk without a port when defined by parent process', testInspectRemoval, '--inspect-brk');87+test('The "nodeOptions" option removes --inspect-brk with a port when defined by parent process', testInspectRemoval, '--inspect-brk=9223');88 72-test('node allows --inspect with a different port from nodeOptions even when defined by parent process', async t => {89+test('The "nodeOptions" option allows --inspect with a different port even when defined by parent process', async t => {90 const {stdout, stdio} = await spawnNestedExecaNode(['--inspect=9225'], '', '--inspect=9224');91 t.is(stdout, foobarString);92 t.true(stdio[3].includes('Debugger listening'));93 });94 78-test('node forbids --inspect with the same port from nodeOptions when defined by parent process', async t => {95+test('The "nodeOptions" option forbids --inspect with the same port when defined by parent process', async t => {96 const {stdout, stdio} = await spawnNestedExecaNode(['--inspect=9226'], '', '--inspect=9226');97 t.is(stdout, foobarString);98 t.true(stdio[3].includes('address already in use'));99 });100 84-test('node\'s forked script has a communication channel', async t => {85- const subprocess = execaNode('test/fixtures/send.js');101+const runWithIpc = (file, options) => execa('node', [file], {...options, ipc: true});102+103+const testIpc = async (t, execaMethod, options) => {104+ const subprocess = execaMethod('send.js', options);105 await pEvent(subprocess, 'message');106+ subprocess.send(foobarString);107+ const {stdout, stdio} = await subprocess;108+ t.is(stdout, foobarString);109+ t.is(stdio.length, 4);110+ t.is(stdio[3], undefined);111+};112 88- subprocess.send('ping');113+test('execaNode() adds an ipc channel', testIpc, execaNode, {});114+test('The "ipc" option adds an ipc channel', testIpc, runWithIpc, {});115+test('The "ipc" option works with "stdio: \'pipe\'"', testIpc, runWithIpc, {stdio: 'pipe'});116+test('The "ipc" option works with "stdio: [\'pipe\', \'pipe\', \'pipe\']"', testIpc, runWithIpc, {stdio: ['pipe', 'pipe', 'pipe']});117+test('The "ipc" option works with "stdio: [\'pipe\', \'pipe\', \'pipe\', \'ipc\']"', testIpc, runWithIpc, {stdio: ['pipe', 'pipe', 'pipe', 'ipc']});118+test('The "ipc" option works with "stdout: \'pipe\'"', testIpc, runWithIpc, {stdout: 'pipe'});119 90- const message = await pEvent(subprocess, 'message');91- t.is(message, 'pong');120+test('No ipc channel is added by default', async t => {121+ const {stdio} = await t.throwsAsync(execa('node', ['send.js']), {message: /process.send is not a function/});122+ t.is(stdio.length, 3);123+});124 93- subprocess.kill();125+test('Can disable "ipc" with execaNode', async t => {126+ const {stdio} = await t.throwsAsync(execaNode('send.js', {ipc: false}), {message: /process.send is not a function/});127+ t.is(stdio.length, 3);128+});129 95- const {signal} = await t.throwsAsync(subprocess);96- t.is(signal, 'SIGTERM');130+test('Cannot use the "ipc" option with execaSync()', t => {131+ t.throws(() => {132+ execaSync('node', ['send.js'], {ipc: true});133+ }, {message: /The "ipc: true" option cannot be used/});134 });modified:test/test.js+9 added-11 removed
1 unmodified line2 import process from 'node:process';3 import {fileURLToPath, pathToFileURL} from 'node:url';4 import test from 'ava';5 import isRunning from 'is-running';6-import getNode from 'get-node';6 import which from 'which';7 import {execa, execaSync, execaNode, $} from '../index.js';8 import {setFixtureDir, PATH_KEY, FIXTURES_DIR_URL} from './helpers/fixtures-dir.js';9 import {identity, fullStdio, getStdio} from './helpers/stdio.js';10 import {noopGenerator} from './helpers/generator.js';11+import {foobarString} from './helpers/input.js';12 13 setFixtureDir();14 process.env.FOO = 'foo';15 41 unmodified lines57 t.is(stdout, 'Hello World');58 });59 }60 61+const testNullOptions = async (t, execaMethod) => {62+ const {stdout} = await execaMethod('noop.js', [foobarString], null);63+ t.is(stdout, foobarString);64+};65+66+test('Can pass null to options', testNullOptions, execa);67+test('Can pass null to options - sync', testNullOptions, execaSync);68+69 test('execaSync() throws error if ENOENT', t => {70 t.throws(() => {71 execaSync('foo');72 }, {message: ENOENT_REGEXP});71 unmodified lines144 const envPaths = stdout.split(path.delimiter);145 t.true(envPaths.some(envPath => envPath.endsWith('.bin')));146 });147 140-const testExecPath = async (t, mapPath) => {141- const {path} = await getNode('16.0.0');142- const execPath = mapPath(path);143- const {stdout} = await execa('node', ['-p', 'process.env.Path || process.env.PATH'], {preferLocal: true, execPath});144- t.true(stdout.includes('16.0.0'));145-};146-147-test.serial('execPath option', testExecPath, identity);148-test.serial('execPath option can be a file URL', testExecPath, pathToFileURL);149-148 test('execa() returns a promise with pid', async t => {149 const subprocess = execa('noop.js', ['foo']);150 t.is(typeof subprocess.pid, 'number');151 await subprocess;170 unmodified linesmodified:index.d.ts+17 added-15 removed
307 unmodified lines308 [How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the child process' standard input. This can be:309 - `'pipe'`: Sets [`childProcess.stdin`](https://nodejs.org/api/child_process.html#subprocessstdin) stream.310 - `'overlapped'`: Like `'pipe'` but asynchronous on Windows.311 - `'ignore'`: Do not use `stdin`.312- - `'ipc'`: Sets an [IPC channel](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback). You can also use `execaNode()` instead.312 - `'inherit'`: Re-use the current process' `stdin`.313 - an integer: Re-use a specific file descriptor from the current process.314 - a Node.js `Readable` stream.315 - `{ file: 'path' }` object.14 unmodified lines330 [How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the child process' standard output. This can be:331 - `'pipe'`: Sets `childProcessResult.stdout` (as a string or `Uint8Array`) and [`childProcess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout) (as a stream).332 - `'overlapped'`: Like `'pipe'` but asynchronous on Windows.333 - `'ignore'`: Do not use `stdout`.335- - `'ipc'`: Sets an [IPC channel](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback). You can also use `execaNode()` instead.334 - `'inherit'`: Re-use the current process' `stdout`.335 - an integer: Re-use a specific file descriptor from the current process.336 - a Node.js `Writable` stream.337 - `{ file: 'path' }` object.12 unmodified lines350 [How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the child process' standard error. This can be:351 - `'pipe'`: Sets `childProcessResult.stderr` (as a string or `Uint8Array`) and [`childProcess.stderr`](https://nodejs.org/api/child_process.html#subprocessstderr) (as a stream).352 - `'overlapped'`: Like `'pipe'` but asynchronous on Windows.353 - `'ignore'`: Do not use `stderr`.356- - `'ipc'`: Sets an [IPC channel](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback). You can also use `execaNode()` instead.354 - `'inherit'`: Re-use the current process' `stderr`.355 - an integer: Re-use a specific file descriptor from the current process.356 - a Node.js `Writable` stream.357 - `{ file: 'path' }` object.12 unmodified lines370 Like the `stdin`, `stdout` and `stderr` options but for all file descriptors at once. For example, `{stdio: ['ignore', 'pipe', 'pipe']}` is the same as `{stdin: 'ignore', stdout: 'pipe', stderr: 'pipe'}`.371 372 A single string can be used as a shortcut. For example, `{stdio: 'pipe'}` is the same as `{stdin: 'pipe', stdout: 'pipe', stderr: 'pipe'}`.373 377- The array can have more than 3 items, to create additional file descriptors beyond `stdin`/`stdout`/`stderr`. For example, `{stdio: ['pipe', 'pipe', 'pipe', 'ipc']}` sets a fourth file descriptor `'ipc'`.374+ The array can have more than 3 items, to create additional file descriptors beyond `stdin`/`stdout`/`stderr`. For example, `{stdio: ['pipe', 'pipe', 'pipe', 'pipe']}` sets a fourth file descriptor.375 376 @default 'pipe'377 */378 readonly stdio?: StdioOptions<IsSync>;175 unmodified lines554 */555 readonly all?: IfAsync<IsSync, boolean>;556 557 /**558+ Enables exchanging messages with the child process using [`childProcess.send(value)`](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback) and [`childProcess.on('message', (value) => {})`](https://nodejs.org/api/child_process.html#event-message).559+ */560+ readonly ipc?: IfAsync<IsSync, boolean>;561+562+ /**561- Specify the kind of serialization used for sending messages between processes when using the `stdio: 'ipc'` option or `execaNode()`:563+ Specify the kind of serialization used for sending messages between processes when using the `ipc` option:564 - `json`: Uses `JSON.stringify()` and `JSON.parse()`.565 - `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)566 567 [More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)90 unmodified lines658 659 /**660 The output of the process on `stdout`.661 660- This is `undefined` if the `stdout` option is set to only [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the `lines` option is `true, or if the `stdout` option is a transform in object mode.662+ This is `undefined` if the `stdout` option is set to only [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the `lines` option is `true, or if the `stdout` option is a transform in object mode.663 */664 stdout: StdioOutput<'1', OptionsType>;665 666 /**667 The output of the process on `stderr`.668 667- This is `undefined` if the `stderr` option is set to only [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the `lines` option is `true, or if the `stderr` option is a transform in object mode.669+ This is `undefined` if the `stderr` option is set to only [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the `lines` option is `true, or if the `stderr` option is a transform in object mode.670 */671 stderr: StdioOutput<'2', OptionsType>;672 673 /**674 The output of the process on `stdin`, `stdout`, `stderr` and other file descriptors.675 674- Items are `undefined` when their corresponding `stdio` option is set to only [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). Items are arrays when their corresponding `stdio` option is a transform in object mode.676+ Items are `undefined` when their corresponding `stdio` option is set to only [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). Items are arrays when their corresponding `stdio` option is a transform in object mode.677 */678 stdio: StdioArrayOutput<OptionsType>;679 680 /**43 unmodified lines724 The output of the process with `stdout` and `stderr` interleaved.725 726 This is `undefined` if either:727 - the `all` option is `false` (default value)726- - both `stdout` and `stderr` options are set to [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)728+ - both `stdout` and `stderr` options are set to [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)729 730 This is an array if the `lines` option is `true, or if either the `stdout` or `stderr` option is a transform in object mode.731 */732 all: IfAsync<IsSync, AllOutput<OptionsType>>;69 unmodified lines802 Stream combining/interleaving [`stdout`](https://nodejs.org/api/child_process.html#child_process_subprocess_stdout) and [`stderr`](https://nodejs.org/api/child_process.html#child_process_subprocess_stderr).803 804 This is `undefined` if either:805 - the `all` option is `false` (the default value)804- - both `stdout` and `stderr` options are set to [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)806+ - both `stdout` and `stderr` options are set to [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)807 */808 all: AllStream<OptionsType>;809 810 catch<ResultType = never>(128 unmodified lines939 940 /**941 Same as `execa()` but synchronous.942 941-Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization`, `signal` and `lines`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, an iterable or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.943+Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `ipc`, `serialization`, `signal` and `lines`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, an iterable or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.944 945 Returns or throws a `childProcessResult`. The `childProcess` is not returned: its methods and properties are not available. This includes [`.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`.pid`](https://nodejs.org/api/child_process.html#subprocesspid), `.pipe()` and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.946 947 @param file - The program/script to execute, as a string or file URL92 unmodified lines1040 1041 /**1042 Same as `execaCommand()` but synchronous.1043 1042-Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization`, `signal` and `lines`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, an iterable or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1044+Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `ipc`, `serialization`, `signal` and `lines`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, an iterable or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1045 1046 Returns or throws a `childProcessResult`. The `childProcess` is not returned: its methods and properties are not available. This includes [`.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`.pid`](https://nodejs.org/api/child_process.html#subprocesspid), `.pipe()` and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.1047 1048 @param command - The program/script to execute and its arguments.50 unmodified lines1099 1100 /**1101 Same as $\`command\` but synchronous.1102 1101- Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization`, `signal` and `lines`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, an iterable or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1103+ Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `ipc`, `serialization`, `signal` and `lines`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, an iterable or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1104 1105 Returns or throws a `childProcessResult`. The `childProcess` is not returned: its methods and properties are not available. This includes [`.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`.pid`](https://nodejs.org/api/child_process.html#subprocesspid), `.pipe()` and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.1106 1107 @returns A `childProcessResult` object45 unmodified lines1153 1154 /**1155 Same as $\`command\` but synchronous.1156 1155- Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization`, `signal` and `lines`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, an iterable or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1157+ Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `ipc`, `serialization`, `signal` and `lines`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, an iterable or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1158 1159 Returns or throws a `childProcessResult`. The `childProcess` is not returned: its methods and properties are not available. This includes [`.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`.pid`](https://nodejs.org/api/child_process.html#subprocesspid), `.pipe()` and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.1160 1161 @returns A `childProcessResult` object108 unmodified lines1270 1271 Like [`child_process#fork()`](https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options):1272 - the current Node version and options are used. This can be overridden using the `nodePath` and `nodeOptions` options.1273 - the `shell` option cannot be used1272-- an extra channel [`ipc`](https://nodejs.org/api/child_process.html#child_process_options_stdio) is passed to `stdio`1274+- the `ipc` option defaults to `true`1275 1276 @param scriptPath - Node.js script to execute, as a string or file URL1277 @param arguments - Arguments to pass to `scriptPath` on execution.1278 @returns An `ExecaChildProcess` that is both:20 unmodified linesmodified:index.js+13 added-18 removed
8 unmodified lines9 import {npmRunPathEnv} from 'npm-run-path';10 import {makeError} from './lib/error.js';11 import {handleInputAsync, pipeOutputAsync, cleanupStdioStreams} from './lib/stdio/async.js';12 import {handleInputSync, pipeOutputSync} from './lib/stdio/sync.js';13-import {normalizeStdioNode} from './lib/stdio/normalize.js';13 import {spawnedKill, validateTimeout, normalizeForceKillAfterDelay, cleanupOnExit} from './lib/kill.js';14 import {pipeToProcess} from './lib/pipe.js';15 import {getSpawnedResult, makeAllStream} from './lib/stream.js';16 import {mergePromise} from './lib/promise.js';67 unmodified lines84 verbose = verboseDefault,85 killSignal = 'SIGTERM',86 forceKillAfterDelay = true,87 lines = false,88+ ipc = false,89 ...options90 }) => ({91 ...options,92 maxBuffer,12 unmodified lines105 verbose,106 killSignal,107 forceKillAfterDelay,108 lines,109+ ipc,110 });111 112 // Prevent passing the `timeout` option directly to `child_process.spawn()`113 const handleAsyncOptions = ({timeout, ...options}) => ({...options, timeoutDuration: timeout});109 unmodified lines223 };224 225 export function execaSync(rawFile, rawArgs, rawOptions) {226 const {file, args, command, escapedCommand, options} = handleArguments(rawFile, rawArgs, rawOptions);227+ validateSyncOptions(options);228 229 const stdioStreamsGroups = handleInputSync(options);230 231 let result;55 unmodified lines287 isTerminated: false,288 };289 }290 291+const validateSyncOptions = ({ipc}) => {292+ if (ipc) {293+ throw new TypeError('The "ipc: true" option cannot be used with synchronous methods.');294+ }295+};296+297 const normalizeScriptStdin = ({input, inputFile, stdio}) => input === undefined && inputFile === undefined && stdio === undefined298 ? {stdin: 'inherit'}299 : {};300 38 unmodified lines339 const [file, ...args] = parseCommand(command);340 return execaSync(file, args, options);341 }342 335-export function execaNode(scriptPath, args, options = {}) {336- if (args && !Array.isArray(args) && typeof args === 'object') {343+export function execaNode(scriptPath, args = [], options = {}) {344+ if (!Array.isArray(args)) {345 options = args;346 args = [];347 }348 341- const stdio = normalizeStdioNode(options);349 const defaultExecArgv = process.execArgv.filter(arg => !arg.startsWith('--inspect'));343-350 const {351 nodePath = process.execPath,352 nodeOptions = defaultExecArgv,353 } = options;354 355 return execa(356 nodePath,351- [352- ...nodeOptions,353- getFilePath(scriptPath),354- ...(Array.isArray(args) ? args : []),355- ],356- {357- ...options,358- stdin: undefined,359- stdout: undefined,360- stderr: undefined,361- stdio,362- shell: false,363- },357+ [...nodeOptions, getFilePath(scriptPath), ...args],358+ {ipc: true, ...options, shell: false},359 );360 }modified:index.test-d.ts+2 added
1231 unmodified lines1232 expectError(execaSync('unicorns', {stdio: [[[new Uint8Array(), new Uint8Array()]]]}));1233 expectError(execaSync('unicorns', {stdio: [[[{}, {}]]]}));1234 expectError(execaSync('unicorns', {stdio: [[emptyStringGenerator()]]}));1235 expectError(execaSync('unicorns', {stdio: [[asyncStringGenerator()]]}));1236+execa('unicorns', {ipc: true});1237+expectError(execaSync('unicorns', {ipc: true}));1238 execa('unicorns', {serialization: 'advanced'});1239 expectError(execaSync('unicorns', {serialization: 'advanced'}));1240 execa('unicorns', {detached: true});1241 expectError(execaSync('unicorns', {detached: true}));142 unmodified linesmodified:readme.md+18 added-14 removed
242 unmodified lines243 244 Like [`child_process#fork()`](https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options):245 - the current Node version and options are used. This can be overridden using the [`nodePath`](#nodepath-for-node-only) and [`nodeOptions`](#nodeoptions-for-node-only) options.246 - the [`shell`](#shell) option cannot be used247-- an extra channel [`ipc`](https://nodejs.org/api/child_process.html#child_process_options_stdio) is passed to [`stdio`](#stdio-1)247+- the [`ipc`](#ipc) option defaults to `true`248 249 #### $\`command\`250 251 Executes a command. The `command` string includes both the `file` and its `arguments`. Returns a [`childProcess`](#childprocess).25 unmodified lines277 ### execaSync(file, arguments?, options?)278 279 Same as [`execa()`](#execacommandcommand-options) but synchronous.280 281-Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`serialization`](#serialization), [`signal`](#signal) and [`lines`](#lines). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be an array, an iterable or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.281+Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`ipc`](#ipc), [`serialization`](#serialization), [`signal`](#signal) and [`lines`](#lines). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be an array, an iterable or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.282 283 Returns or throws a [`childProcessResult`](#childProcessResult). The [`childProcess`](#childprocess) is not returned: its methods and properties are not available. This includes [`.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`.pid`](https://nodejs.org/api/child_process.html#subprocesspid), [`.pipe()`](#pipeexecachildprocess-streamname) and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.284 285 ### $.sync\`command\`286 ### $.s\`command\`287 288 Same as [$\`command\`](#command) but synchronous.289 290-Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`serialization`](#serialization), [`signal`](#signal) and [`lines`](#lines). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be an array, an iterable or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.290+Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`ipc`](#ipc), [`serialization`](#serialization), [`signal`](#signal) and [`lines`](#lines). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be an array, an iterable or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.291 292 Returns or throws a [`childProcessResult`](#childProcessResult). The [`childProcess`](#childprocess) is not returned: its methods and properties are not available. This includes [`.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`.pid`](https://nodejs.org/api/child_process.html#subprocesspid), [`.pipe()`](#pipeexecachildprocess-streamname) and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.293 294 ### execaCommandSync(command, options?)295 296 Same as [`execaCommand()`](#execacommand-command-options) but synchronous.297 298-Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`serialization`](#serialization), [`signal`](#signal) and [`lines`](#lines). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be an array, an iterable or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.298+Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`ipc`](#ipc), [`serialization`](#serialization), [`signal`](#signal) and [`lines`](#lines). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be an array, an iterable or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.299 300 Returns or throws a [`childProcessResult`](#childProcessResult). The [`childProcess`](#childprocess) is not returned: its methods and properties are not available. This includes [`.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`.pid`](https://nodejs.org/api/child_process.html#subprocesspid), [`.pipe()`](#pipeexecachildprocess-streamname) and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.301 302 ### Shell syntax13 unmodified lines316 Stream [combining/interleaving](#ensuring-all-output-is-interleaved) [`stdout`](https://nodejs.org/api/child_process.html#child_process_subprocess_stdout) and [`stderr`](https://nodejs.org/api/child_process.html#child_process_subprocess_stderr).317 318 This is `undefined` if either:319 - the [`all` option](#all-2) is `false` (the default value)320-- both [`stdout`](#stdout-1) and [`stderr`](#stderr-1) options are set to [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)320+- both [`stdout`](#stdout-1) and [`stderr`](#stderr-1) options are set to [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)321 322 #### pipe(execaChildProcess, streamName?)323 324 `execaChildProcess`: [`execa()` return value](#pipe-multiple-processes)50 unmodified lines375 Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`376 377 The output of the process on `stdout`.378 379-This is `undefined` if the [`stdout`](#stdout-1) option is set to only [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the [`lines` option](#lines) is `true, or if the `stdout` option is a [transform in object mode](docs/transform.md#object-mode).379+This is `undefined` if the [`stdout`](#stdout-1) option is set to only [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the [`lines` option](#lines) is `true, or if the `stdout` option is a [transform in object mode](docs/transform.md#object-mode).380 381 #### stderr382 383 Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`384 385 The output of the process on `stderr`.386 387-This is `undefined` if the [`stderr`](#stderr-1) option is set to only [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the [`lines` option](#lines) is `true, or if the `stderr` option is a [transform in object mode](docs/transform.md#object-mode).387+This is `undefined` if the [`stderr`](#stderr-1) option is set to only [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the [`lines` option](#lines) is `true, or if the `stderr` option is a [transform in object mode](docs/transform.md#object-mode).388 389 #### all390 391 Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`1 unmodified line393 The output of the process with `stdout` and `stderr` [interleaved](#ensuring-all-output-is-interleaved).394 395 This is `undefined` if either:396 - the [`all` option](#all-2) is `false` (the default value)397-- both [`stdout`](#stdout-1) and [`stderr`](#stderr-1) options are set to only [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)397+- both [`stdout`](#stdout-1) and [`stderr`](#stderr-1) options are set to only [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)398 399 This is an array if the [`lines` option](#lines) is `true, or if either the `stdout` or `stderr` option is a [transform in object mode](docs/transform.md#object-mode).400 401 #### stdio1 unmodified line403 Type: `Array<string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined>`404 405 The output of the process on [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1) and [other file descriptors](#stdio-1).406 407-Items are `undefined` when their corresponding [`stdio`](#stdio-1) option is set to [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). Items are arrays when their corresponding `stdio` option is a [transform in object mode](docs/transform.md#object-mode).407+Items are `undefined` when their corresponding [`stdio`](#stdio-1) option is set to [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). Items are arrays when their corresponding `stdio` option is a [transform in object mode](docs/transform.md#object-mode).408 409 #### failed410 411 Type: `boolean`142 unmodified lines554 [How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the child process' standard input. This can be:555 - `'pipe'`: Sets [`childProcess.stdin`](https://nodejs.org/api/child_process.html#subprocessstdin) stream.556 - `'overlapped'`: Like `'pipe'` but asynchronous on Windows.557 - `'ignore'`: Do not use `stdin`.558-- `'ipc'`: Sets an [IPC channel](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback). You can also use [`execaNode()`](#execanodescriptpath-arguments-options) instead.558 - `'inherit'`: Re-use the current process' `stdin`.559 - an integer: Re-use a specific file descriptor from the current process.560 - a [Node.js `Readable` stream](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr).561 - `{ file: 'path' }` object.14 unmodified lines576 [How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the child process' standard output. This can be:577 - `'pipe'`: Sets [`childProcessResult.stdout`](#stdout) (as a string or `Uint8Array`) and [`childProcess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout) (as a stream).578 - `'overlapped'`: Like `'pipe'` but asynchronous on Windows.579 - `'ignore'`: Do not use `stdout`.581-- `'ipc'`: Sets an [IPC channel](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback). You can also use [`execaNode()`](#execanodescriptpath-arguments-options) instead.580 - `'inherit'`: Re-use the current process' `stdout`.581 - an integer: Re-use a specific file descriptor from the current process.582 - a [Node.js `Writable` stream](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr).583 - `{ file: 'path' }` object.12 unmodified lines596 [How to setup](https://nodejs.org/api/child_process.html#child_process_options_stdio) the child process' standard error. This can be:597 - `'pipe'`: Sets [`childProcessResult.stderr`](#stderr) (as a string or `Uint8Array`) and [`childProcess.stderr`](https://nodejs.org/api/child_process.html#subprocessstderr) (as a stream).598 - `'overlapped'`: Like `'pipe'` but asynchronous on Windows.599 - `'ignore'`: Do not use `stderr`.602-- `'ipc'`: Sets an [IPC channel](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback). You can also use [`execaNode()`](#execanodescriptpath-arguments-options) instead.600 - `'inherit'`: Re-use the current process' `stderr`.601 - an integer: Re-use a specific file descriptor from the current process.602 - a [Node.js `Writable` stream](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr).603 - `{ file: 'path' }` object.12 unmodified lines616 Like the [`stdin`](#stdin), [`stdout`](#stdout-1) and [`stderr`](#stderr-1) options but for all file descriptors at once. For example, `{stdio: ['ignore', 'pipe', 'pipe']}` is the same as `{stdin: 'ignore', stdout: 'pipe', stderr: 'pipe'}`.617 618 A single string can be used as a shortcut. For example, `{stdio: 'pipe'}` is the same as `{stdin: 'pipe', stdout: 'pipe', stderr: 'pipe'}`.619 623-The array can have more than 3 items, to create additional file descriptors beyond `stdin`/`stdout`/`stderr`. For example, `{stdio: ['pipe', 'pipe', 'pipe', 'ipc']}` sets a fourth file descriptor `'ipc'`.620+The array can have more than 3 items, to create additional file descriptors beyond `stdin`/`stdout`/`stderr`. For example, `{stdio: ['pipe', 'pipe', 'pipe', 'pipe']}` sets a fourth file descriptor.621 622 #### all623 624 Type: `boolean`\10 unmodified lines635 - [`result.stdout`](#stdout), [`result.stderr`](#stderr), [`result.all`](#all-1) and [`result.stdio`](#stdio) are arrays of lines.636 - [`childProcess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout), [`childProcess.stderr`](https://nodejs.org/api/child_process.html#subprocessstderr), [`childProcess.all`](#all) and [`childProcess.stdio`](https://nodejs.org/api/child_process.html#subprocessstdio) iterate over lines instead of arbitrary chunks.637 - Any stream passed to the [`stdout`](#stdout-1), [`stderr`](#stderr-1) or [`stdio`](#stdio-1) option receives lines instead of arbitrary chunks.638 639+#### ipc640+641+Type: `boolean`\642+Default: `true` with [`execaNode()`](#execanodescriptpath-arguments-options), `false` otherwise643+644+Enables exchanging messages with the child process using [`childProcess.send(value)`](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback) and [`childProcess.on('message', (value) => {})`](https://nodejs.org/api/child_process.html#event-message).645+646 #### reject647 648 Type: `boolean`\649 Default: `true`45 unmodified lines695 696 Type: `string`\697 Default: `'json'`698 695-Specify the kind of serialization used for sending messages between processes when using the [`stdio: 'ipc'`](#stdio-1) option or [`execaNode()`](#execanodescriptpath-arguments-options):699+Specify the kind of serialization used for sending messages between processes when using the [`ipc`](#ipc) option:700 - `json`: Uses `JSON.stringify()` and `JSON.parse()`.701 - `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)702 703 [More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)247 unmodified lines