Add `node` option (#804)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent 2fd9351 · Browse files · 8 files·+229 added−118 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+229 added−118 removed
- tests:+121 added−50 removed
- other:+108 added−68 removed
Provenance
- Commit
663136b- Tree
5ebfad1- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
2fd9351
8 files changed+229 added−118 removed
added:lib/node.js+24 added
123456789101112131415161718192021222324import {execPath, execArgv} from 'node:process';import {basename} from 'node:path';import {safeNormalizeFileUrl} from './cwd.js';
export const handleNodeOption = (file, args, { node: shouldHandleNode = false, nodePath = execPath, nodeOptions = execArgv.filter(arg => !arg.startsWith('--inspect')), ...options}) => { if (!shouldHandleNode) { return [file, args, options]; }
if (basename(file, '.exe') === 'node') { throw new TypeError('When the "node" option is true, the first argument does not need to be "node".'); }
return [ safeNormalizeFileUrl(nodePath, 'The "nodePath" option'), [...nodeOptions, file, ...args], {ipc: true, ...options, shell: false}, ];};modified:test/fixtures/nested-node.js+6 added-3 removed
12344566789101112121314151617#!/usr/bin/env nodeimport process from 'node:process';import {writeSync} from 'node:fs';import {execaNode} from '../../index.js';import {execa, execaNode} from '../../index.js';
const [fakeExecArgv, nodeOptions, file, ...args] = process.argv.slice(2);const [fakeExecArgv, execaMethod, nodeOptions, file, ...args] = process.argv.slice(2);
if (fakeExecArgv !== '') { process.execArgv = [fakeExecArgv];}
const {stdout, stderr} = await execaNode(file, args, {nodeOptions: [nodeOptions].filter(Boolean)});const filteredNodeOptions = [nodeOptions].filter(Boolean);const {stdout, stderr} = await (execaMethod === 'execaNode' ? execaNode(file, args, {nodeOptions: filteredNodeOptions}) : execa(file, args, {nodeOptions: filteredNodeOptions, node: true}));console.log(stdout);writeSync(3, stderr);modified:test/node.js+115 added-38 removed
9 unmodified lines10 import {foobarString} from './helpers/input.js';11 12 process.chdir(FIXTURES_DIR);13 14-test('execaNode() succeeds', async t => {15- const {exitCode} = await execaNode('noop.js');14+const runWithNodeOption = (file, args = [], options = {}) => execa(file, args, {...options, node: true});15+const runWithNodeOptionSync = (file, args = [], options = {}) => execaSync(file, args, {...options, node: true});16+const runWithIpc = (file, options) => execa('node', [file], {...options, ipc: true});17+18+const testNodeSuccess = async (t, execaMethod) => {19+ const {exitCode, stdout} = await execaMethod('noop.js', [foobarString]);20 t.is(exitCode, 0);21+ t.is(stdout, foobarString);17-});22+};23 19-test('execaNode() returns stdout', async t => {20- const {stdout} = await execaNode('noop.js', ['foo']);21- t.is(stdout, 'foo');24+test('execaNode() succeeds', testNodeSuccess, execaNode);25+test('The "node" option succeeds', testNodeSuccess, runWithNodeOption);26+test('The "node" option succeeds - sync', testNodeSuccess, runWithNodeOptionSync);27+28+test('execaNode() cannot set the "node" option to false', t => {29+ t.throws(() => {30+ execaNode('empty.js', {node: false});31+ }, {message: /The "node" option cannot be false/});32 });33 34+const testDoubleNode = (t, execPath, execaMethod) => {35+ t.throws(() => {36+ execaMethod(execPath, ['noop.js']);37+ }, {message: /does not need to be "node"/});38+};39+40+test('Cannot use "node" as binary - execaNode()', testDoubleNode, 'node', execaNode);41+test('Cannot use "node" as binary - "node" option', testDoubleNode, 'node', runWithNodeOption);42+test('Cannot use "node" as binary - "node" option sync', testDoubleNode, 'node', runWithNodeOptionSync);43+test('Cannot use path to "node" as binary - execaNode()', testDoubleNode, process.execPath, execaNode);44+test('Cannot use path to "node" as binary - "node" option', testDoubleNode, process.execPath, runWithNodeOption);45+test('Cannot use path to "node" as binary - "node" option sync', testDoubleNode, process.execPath, runWithNodeOptionSync);46+47 const getNodePath = async () => {48 const {path} = await getNode(TEST_NODE_VERSION);49 return path;50 };51 52 const TEST_NODE_VERSION = '16.0.0';53 31-const testNodePath = async (t, mapPath) => {54+const testNodePath = async (t, execaMethod, mapPath) => {55 const nodePath = mapPath(await getNodePath());33- const {stdout} = await execaNode('--version', {nodePath});56+ const {stdout} = await execaMethod('--version', [], {nodePath});57 t.is(stdout, `v${TEST_NODE_VERSION}`);58 };59 37-test.serial('The "nodePath" option can be used', testNodePath, identity);38-test.serial('The "nodePath" option can be a file URL', testNodePath, pathToFileURL);60+test.serial('The "nodePath" option can be used - execaNode()', testNodePath, execaNode, identity);61+test.serial('The "nodePath" option can be a file URL - execaNode()', testNodePath, execaNode, pathToFileURL);62+test.serial('The "nodePath" option can be used - "node" option', testNodePath, runWithNodeOption, identity);63+test.serial('The "nodePath" option can be a file URL - "node" option', testNodePath, runWithNodeOption, pathToFileURL);64 40-test('The "nodePath" option defaults to the current Node.js binary', async t => {41- const {stdout} = await execaNode('--version');65+const testNodePathDefault = async (t, execaMethod) => {66+ const {stdout} = await execaMethod('--version');67 t.is(stdout, process.version);43-});68+};69 70+test('The "nodePath" option defaults to the current Node.js binary - execaNode()', testNodePathDefault, execaNode);71+test('The "nodePath" option defaults to the current Node.js binary - "node" option', testNodePathDefault, runWithNodeOption);72+73+const testNodePathInvalid = (t, execaMethod) => {74+ t.throws(() => {75+ execaMethod('noop.js', [], {nodePath: true});76+ }, {message: /The "nodePath" option must be a string or a file URL/});77+};78+79+test('The "nodePath" option must be a string or URL - execaNode()', testNodePathInvalid, execaNode);80+test('The "nodePath" option must be a string or URL - "node" option', testNodePathInvalid, runWithNodeOption);81+test('The "nodePath" option must be a string or URL - "node" option sync', testNodePathInvalid, runWithNodeOptionSync);82+83 const nodePathArguments = ['node', ['-p', 'process.env.Path || process.env.PATH']];84 85 const testExecPath = async (t, mapPath) => {86 const execPath = mapPath(await getNodePath());14 unmodified lines101 const {stdout} = await execa(...nodePathArguments, {execPath});102 t.false(stdout.includes(TEST_NODE_VERSION));103 });104 67-test('The "nodeOptions" option can be used', async t => {68- const {stdout} = await execaNode('empty.js', {nodeOptions: ['--version']});105+const testNodeOptions = async (t, execaMethod) => {106+ const {stdout} = await execaMethod('empty.js', [], {nodeOptions: ['--version']});107 t.is(stdout, process.version);70-});108+};109 110+test('The "nodeOptions" option can be used - execaNode()', testNodeOptions, execaNode);111+test('The "nodeOptions" option can be used - "node" option', testNodeOptions, runWithNodeOption);112+72-const spawnNestedExecaNode = (realExecArgv, fakeExecArgv, nodeOptions) => execa(113+const spawnNestedExecaNode = (realExecArgv, fakeExecArgv, execaMethod, nodeOptions) => execa(114 'node',74- [...realExecArgv, 'nested-node.js', fakeExecArgv, nodeOptions, 'noop.js', foobarString],115+ [...realExecArgv, 'nested-node.js', fakeExecArgv, execaMethod, nodeOptions, 'noop.js', foobarString],116 {...fullStdio, cwd: FIXTURES_DIR},117 );118 78-const testInspectRemoval = async (t, fakeExecArgv) => {79- const {stdout, stdio} = await spawnNestedExecaNode([], fakeExecArgv, '');119+const testInspectRemoval = async (t, fakeExecArgv, execaMethod) => {120+ const {stdout, stdio} = await spawnNestedExecaNode([], fakeExecArgv, execaMethod, '');121 t.is(stdout, foobarString);122 t.is(stdio[3], '');123 };124 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');125+test('The "nodeOptions" option removes --inspect without a port when defined by parent process - execaNode()', testInspectRemoval, '--inspect', 'execaNode');126+test('The "nodeOptions" option removes --inspect without a port when defined by parent process - "node" option', testInspectRemoval, '--inspect', 'nodeOption');127+test('The "nodeOptions" option removes --inspect with a port when defined by parent process - execaNode()', testInspectRemoval, '--inspect=9222', 'execaNode');128+test('The "nodeOptions" option removes --inspect with a port when defined by parent process - "node" option', testInspectRemoval, '--inspect=9222', 'nodeOption');129+test('The "nodeOptions" option removes --inspect-brk without a port when defined by parent process - execaNode()', testInspectRemoval, '--inspect-brk', 'execaNode');130+test('The "nodeOptions" option removes --inspect-brk without a port when defined by parent process - "node" option', testInspectRemoval, '--inspect-brk', 'nodeOption');131+test('The "nodeOptions" option removes --inspect-brk with a port when defined by parent process - execaNode()', testInspectRemoval, '--inspect-brk=9223', 'execaNode');132+test('The "nodeOptions" option removes --inspect-brk with a port when defined by parent process - "node" option', testInspectRemoval, '--inspect-brk=9223', 'nodeOption');133 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');134+const testInspectDifferentPort = async (t, execaMethod) => {135+ const {stdout, stdio} = await spawnNestedExecaNode(['--inspect=9225'], '', execaMethod, '--inspect=9224');136 t.is(stdout, foobarString);137 t.true(stdio[3].includes('Debugger listening'));93-});138+};139 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');140+test.serial('The "nodeOptions" option allows --inspect with a different port even when defined by parent process - execaNode()', testInspectDifferentPort, 'execaNode');141+test.serial('The "nodeOptions" option allows --inspect with a different port even when defined by parent process - "node" option', testInspectDifferentPort, 'nodeOption');142+143+const testInspectSamePort = async (t, execaMethod) => {144+ const {stdout, stdio} = await spawnNestedExecaNode(['--inspect=9226'], '', execaMethod, '--inspect=9226');145 t.is(stdout, foobarString);146 t.true(stdio[3].includes('address already in use'));99-});147+};148 101-const runWithIpc = (file, options) => execa('node', [file], {...options, ipc: true});149+test.serial('The "nodeOptions" option forbids --inspect with the same port when defined by parent process - execaNode()', testInspectSamePort, 'execaNode');150+test.serial('The "nodeOptions" option forbids --inspect with the same port when defined by parent process - "node" option', testInspectSamePort, 'nodeOption');151 152 const testIpc = async (t, execaMethod, options) => {104- const subprocess = execaMethod('send.js', options);153+ const subprocess = execaMethod('send.js', [], options);154 await pEvent(subprocess, 'message');155 subprocess.send(foobarString);156 const {stdout, stdio} = await subprocess;157 t.is(stdout, foobarString);1 unmodified line159 t.is(stdio[3], undefined);160 };161 162 test('execaNode() adds an ipc channel', testIpc, execaNode, {});163+test('The "node" option adds an ipc channel', testIpc, runWithNodeOption, {});164 test('The "ipc" option adds an ipc channel', testIpc, runWithIpc, {});165 test('The "ipc" option works with "stdio: \'pipe\'"', testIpc, runWithIpc, {stdio: 'pipe'});166 test('The "ipc" option works with "stdio: [\'pipe\', \'pipe\', \'pipe\']"', testIpc, runWithIpc, {stdio: ['pipe', 'pipe', 'pipe']});167 test('The "ipc" option works with "stdio: [\'pipe\', \'pipe\', \'pipe\', \'ipc\']"', testIpc, runWithIpc, {stdio: ['pipe', 'pipe', 'pipe', 'ipc']});3 unmodified lines171 const {stdio} = await t.throwsAsync(execa('node', ['send.js']), {message: /process.send is not a function/});172 t.is(stdio.length, 3);173 });174 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/});175+const testDisableIpc = async (t, execaMethod) => {176+ const {failed, message, stdio} = await execaMethod('send.js', [], {ipc: false, reject: false});177+ t.true(failed);178+ t.true(message.includes('process.send is not a function'));179 t.is(stdio.length, 3);128-});180+};181 130-test('Cannot use the "ipc" option with execaSync()', t => {182+test('Can disable "ipc" - execaNode()', testDisableIpc, execaNode);183+test('Can disable "ipc" - "node" option', testDisableIpc, runWithNodeOption);184+test('Can disable "ipc" - "node" option sync', testDisableIpc, runWithNodeOptionSync);185+186+const NO_IPC_MESSAGE = /The "ipc: true" option cannot be used/;187+188+const testNoIpcSync = (t, node) => {189 t.throws(() => {132- execaSync('node', ['send.js'], {ipc: true});133- }, {message: /The "ipc: true" option cannot be used/});190+ execaSync('node', ['send.js'], {ipc: true, node});191+ }, {message: NO_IPC_MESSAGE});192+};193+194+test('Cannot use "ipc: true" with execaSync()', testNoIpcSync, undefined);195+test('Cannot use "ipc: true" with execaSync() - "node: false"', testNoIpcSync, false);196+197+test('Cannot use "ipc: true" with execaSync() - "node: true"', t => {198+ t.throws(() => {199+ execaSync('send.js', {ipc: true, node: true});200+ }, {message: NO_IPC_MESSAGE});201 });202+203+const testNoShell = async (t, execaMethod) => {204+ const {failed, message} = await execaMethod('node --version', [], {shell: true, reject: false});205+ t.true(failed);206+ t.true(message.includes('MODULE_NOT_FOUND'));207+};208+209+test('Cannot use "shell: true" - execaNode()', testNoShell, execaNode);210+test('Cannot use "shell: true" - "node" option', testNoShell, runWithNodeOption);211+test('Cannot use "shell: true" - "node" option sync', testNoShell, runWithNodeOptionSync);modified:test/test.js-9 removed
6 unmodified lines7 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';11 12 setFixtureDir();13 process.env.FOO = 'foo';14 42 unmodified lines57 t.is(stdout, 'Hello World');58 });59 }60 62-const testNullOptions = async (t, execaMethod) => {63- const {stdout} = await execaMethod('noop.js', [foobarString], null);64- t.is(stdout, foobarString);65-};66-67-test('Can pass null to options', testNullOptions, execa);68-test('Can pass null to options - sync', testNullOptions, execaSync);69-61 test('execaSync() throws error if ENOENT', t => {62 t.throws(() => {63 execaSync('foo');64 }, {message: ENOENT_REGEXP});236 unmodified linesmodified:index.d.ts+33 added-29 removed
276 unmodified lines277 */278 readonly localDir?: string | URL;279 280 /**281+ If `true`, runs with Node.js. The first argument must be a Node.js file.282+283+ @default `true` with `execaNode()`, `false` otherwise284+ */285+ readonly node?: boolean;286+287+ /**288+ Node.js executable used to create the child process.289+290+ Requires the `node` option to be `true`.291+292+ @default [`process.execPath`](https://nodejs.org/api/process.html#process_process_execpath) (current Node.js executable)293+ */294+ readonly nodePath?: string | URL;295+296+ /**297+ List of [CLI options](https://nodejs.org/api/cli.html#cli_options) passed to the Node.js executable.298+299+ Requires the `node` option to be `true`.300+301+ @default [`process.execArgv`](https://nodejs.org/api/process.html#process_process_execargv) (current Node.js CLI options)302+ */303+ readonly nodeOptions?: string[];304+305+ /**306 Path to the Node.js executable to use in child processes.307 283- Requires `preferLocal` to be `true`.308+ Requires the `preferLocal` option to be `true`.309 310 For example, this can be used together with [`get-node`](https://github.com/ehmicky/get-node) to run a specific Node.js version in a child process.311 287- @default process.execPath312+ @default [`process.execPath`](https://nodejs.org/api/process.html#process_process_execpath) (current Node.js executable)313 */314 readonly execPath?: string | URL;315 316 /**263 unmodified lines580 readonly all?: IfAsync<IsSync, boolean>;581 582 /**583 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).584+585+ @default `true` if the `node` option is enabled, `false` otherwise586 */587 readonly ipc?: IfAsync<IsSync, boolean>;588 589 /**43 unmodified lines633 634 export type Options = CommonOptions<false>;635 export type SyncOptions = CommonOptions<true>;636 610-export type NodeOptions<OptionsType extends Options = Options> = {611- /**612- The Node.js executable to use.613-614- @default process.execPath615- */616- readonly nodePath?: string | URL;617-618- /**619- List of [CLI options](https://nodejs.org/api/cli.html#cli_options) passed to the Node.js executable.620-621- @default process.execArgv622- */623- readonly nodeOptions?: string[];624-} & OptionsType;625-637 /**638 Result of a child process execution. On success this is a plain object. On failure this is also an `Error` instance.639 640 The child process fails when:631 unmodified lines1272 */1273 export const $: Execa$;1274 1275 /**1265-Executes a Node.js file using `node scriptPath ...arguments`. `file` is a string or a file URL. `arguments` are an array of strings. Returns a `childProcess`.1276+Same as `execa()` but using the `node` option.1277 1267-Arguments are automatically escaped. They can contain any character, including spaces.1278+Executes a Node.js file using `node scriptPath ...arguments`.1279 1269-This is the preferred method when executing Node.js files.1270-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 used1274-- the `ipc` option defaults to `true`1275-1280 @param scriptPath - Node.js script to execute, as a string or file URL1281 @param arguments - Arguments to pass to `scriptPath` on execution.1282 @returns An `ExecaChildProcess` that is both:1283 - a `Promise` resolving or rejecting with a `childProcessResult`.6 unmodified lines1290 1291 await execaNode('scriptPath', ['argument']);1292 ```1293 */1290-export function execaNode<OptionsType extends NodeOptions = {}>(1294+export function execaNode<OptionsType extends Options = {}>(1295 scriptPath: string | URL,1296 arguments?: readonly string[],1297 options?: OptionsType1298 ): ExecaChildProcess<OptionsType>;1295-export function execaNode<OptionsType extends NodeOptions = {}>(1299+export function execaNode<OptionsType extends Options = {}>(1300 scriptPath: string | URL,1301 options?: OptionsType1302 ): ExecaChildProcess<OptionsType>;modified:index.js+13 added-13 removed
5 unmodified lines6 import crossSpawn from 'cross-spawn';7 import stripFinalNewline from 'strip-final-newline';8 import {npmRunPathEnv} from 'npm-run-path';9 import {makeError} from './lib/error.js';10+import {handleNodeOption} from './lib/node.js';11 import {handleInputAsync, pipeOutputAsync, cleanupStdioStreams} from './lib/stdio/async.js';12 import {handleInputSync, pipeOutputSync} from './lib/stdio/sync.js';13 import {spawnedKill, validateTimeout, normalizeForceKillAfterDelay, cleanupOnExit} from './lib/kill.js';14 import {pipeToProcess} from './lib/pipe.js';24 unmodified lines39 const filePath = getFilePath(rawFile);40 const command = joinCommand(filePath, rawArgs);41 const escapedCommand = getEscapedCommand(filePath, rawArgs);42 42- const {command: file, args, options: initialOptions} = crossSpawn._parse(filePath, rawArgs, rawOptions);43+ const [processedFile, processedArgs, processedOptions] = handleNodeOption(filePath, rawArgs, rawOptions);44 45+ const {command: file, args, options: initialOptions} = crossSpawn._parse(processedFile, processedArgs, processedOptions);46+47 const options = addDefaultOptions(initialOptions);48 validateTimeout(options);49 options.shell = normalizeFileUrl(options.shell);50 options.env = getEnv(options);166 unmodified lines217 };218 };219 220 export function execaSync(rawFile, rawArgs, rawOptions) {221+ const syncOptions = normalizeSyncOptions(rawOptions);218- const {file, args, command, escapedCommand, options} = handleArguments(rawFile, rawArgs, rawOptions);222+ const {file, args, command, escapedCommand, options} = handleArguments(rawFile, rawArgs, syncOptions);223 validateSyncOptions(options);224 225 const stdioStreamsGroups = handleInputSync(options);226 57 unmodified lines284 stdio,285 };286 }287 288+const normalizeSyncOptions = (options = {}) => options.node && !options.ipc ? {...options, ipc: false} : options;289+290 const validateSyncOptions = ({ipc}) => {291 if (ipc) {292 throw new TypeError('The "ipc: true" option cannot be used with synchronous methods.');293 }44 unmodified lines338 const [file, ...args] = parseCommand(command);339 return execaSync(file, args, options);340 }341 336-export function execaNode(scriptPath, args = [], options = {}) {342+export function execaNode(file, args = [], options = {}) {343 if (!Array.isArray(args)) {344 options = args;345 args = [];346 }347 342- const defaultExecArgv = process.execArgv.filter(arg => !arg.startsWith('--inspect'));343- const {344- nodePath = process.execPath,345- nodeOptions = defaultExecArgv,346- } = options;348+ if (options.node === false) {349+ throw new TypeError('The "node" option cannot be false with `execaNode()`.');350+ }351 348- return execa(349- nodePath,350- [...nodeOptions, getFilePath(scriptPath), ...args],351- {ipc: true, ...options, shell: false},352- );352+ return execa(file, args, {...options, node: true});353 }modified:index.test-d.ts+8 added
1247 unmodified lines1248 execa('unicorns', {shell: '/bin/sh'});1249 execaSync('unicorns', {shell: '/bin/sh'});1250 execa('unicorns', {shell: fileUrl});1251 execaSync('unicorns', {shell: fileUrl});1252+execa('unicorns', {node: true});1253+execaSync('unicorns', {node: true});1254+execa('unicorns', {nodePath: './node'});1255+execaSync('unicorns', {nodePath: './node'});1256+execa('unicorns', {nodePath: fileUrl});1257+execaSync('unicorns', {nodePath: fileUrl});1258+execa('unicorns', {nodeOptions: ['--async-stack-traces']});1259+execaSync('unicorns', {nodeOptions: ['--async-stack-traces']});1260 execa('unicorns', {timeout: 1000});1261 execaSync('unicorns', {timeout: 1000});1262 execa('unicorns', {maxBuffer: 1000});1263 execaSync('unicorns', {maxBuffer: 1000});128 unmodified linesmodified:readme.md+30 added-26 removed
231 unmodified lines232 Arguments are [automatically escaped](#shell-syntax). They can contain any character, including spaces.233 234 This is the preferred method when executing single commands.235 236-#### execaNode(scriptPath, arguments?, options?)237-238-Executes a Node.js file using `node scriptPath ...arguments`. `file` is a string or a file URL. `arguments` are an array of strings. Returns a [`childProcess`](#childprocess).239-240-Arguments are [automatically escaped](#shell-syntax). They can contain any character, including spaces.241-242-This is the preferred method when executing Node.js files.243-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-- the [`ipc`](#ipc) option defaults to `true`248-236 #### $\`command\`237 238 Executes a command. The `command` string includes both the `file` and its `arguments`. Returns a [`childProcess`](#childprocess).239 20 unmodified lines260 Arguments are [automatically escaped](#shell-syntax). They can contain any character, but spaces must be escaped with a backslash like `execaCommand('echo has\\ space')`.261 262 This is the preferred method when executing a user-supplied `command` string, such as in a REPL.263 264+#### execaNode(scriptPath, arguments?, options?)265+266+Same as [`execa()`](#execacommandcommand-options) but using the [`node`](#node) option.267+268+Executes a Node.js file using `node scriptPath ...arguments`.269+270 #### execaSync(file, arguments?, options?)271 272 Same as [`execa()`](#execacommandcommand-options) but synchronous.273 262 unmodified lines536 Default: `process.cwd()`537 538 Preferred path to find locally installed binaries in (use with `preferLocal`).539 547-#### execPath540+#### node541 549-Type: `string | URL`\550-Default: `process.execPath` (Current Node.js executable)542+Type: `boolean`\543+Default: `true` with [`execaNode()`](#execanodescriptpath-arguments-options), `false` otherwise544 552-Path to the Node.js executable to use in child processes.545+If `true`, runs with Node.js. The first argument must be a Node.js file.546 554-Requires [`preferLocal`](#preferlocal) to be `true`.547+#### nodeOptions548 556-For example, this can be used together with [`get-node`](https://github.com/ehmicky/get-node) to run a specific Node.js version in a child process.549+Type: `string[]`\550+Default: [`process.execArgv`](https://nodejs.org/api/process.html#process_process_execargv) (current Node.js CLI options)551 558-#### nodePath *(For `.node()` only)*552+List of [CLI options](https://nodejs.org/api/cli.html#cli_options) passed to the [Node.js executable](#nodepath).553 554+Requires the [`node`](#node) option to be `true`.555+556+#### nodePath557+558 Type: `string | URL`\561-Default: [`process.execPath`](https://nodejs.org/api/process.html#process_process_execpath)559+Default: [`process.execPath`](https://nodejs.org/api/process.html#process_process_execpath) (current Node.js executable)560 561 Node.js executable used to create the child process.562 565-#### nodeOptions *(For `.node()` only)*563+Requires the [`node`](#node) option to be `true`.564 567-Type: `string[]`\568-Default: [`process.execArgv`](https://nodejs.org/api/process.html#process_process_execargv)565+#### execPath566 570-List of [CLI options](https://nodejs.org/api/cli.html#cli_options) passed to the Node.js executable.567+Type: `string | URL`\568+Default: [`process.execPath`](https://nodejs.org/api/process.html#process_process_execpath) (current Node.js executable)569 570+Path to the Node.js executable to use in child processes.571+572+Requires the [`preferLocal`](#preferlocal) option to be `true`.573+574+For example, this can be used together with [`get-node`](https://github.com/ehmicky/get-node) to run a specific Node.js version in a child process.575+576 #### verbose577 578 Type: `boolean`\579 Default: `false`142 unmodified lines722 723 #### ipc724 725 Type: `boolean`\722-Default: `true` with [`execaNode()`](#execanodescriptpath-arguments-options), `false` otherwise726+Default: `true` if the [`node`](#node) option is enabled, `false` otherwise727 728 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).729 730 #### serialization223 unmodified lines