Improve validation of `execaSync()` `stdio` option (#941)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent f6e1ac1 · Browse files · 11 files·+176 added−36 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
11 files+176 added−36 removed
- tests:+99 added−20 removed
- other:+77 added−16 removed
Provenance
- Commit
cc565f9- Tree
30e0591- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
f6e1ac1
11 files changed+176 added−36 removed
modified:lib/stdio/handle.js+3 added-3 removed
23 unmodified lines24252627282829303132333435363737383940412 unmodified lines4445464748484950515272 unmodified lines23 unmodified lines// For example, `stdout: ['ignore']` behaves the same as `stdout: 'ignore'`.const getFileDescriptor = ({stdioOption, fdNumber, addProperties, options, isSync, stdioState, verboseInfo}) => { const outputLines = []; const optionName = getOptionName(fdNumber); const stdioItems = initializeStdioItems(stdioOption, fdNumber, options, optionName); const stdioItems = initializeStdioItems({stdioOption, fdNumber, options, isSync, optionName}); const direction = getStreamDirection(stdioItems, fdNumber, optionName); const normalizedStdioItems = normalizeStdioItems({stdioItems, fdNumber, optionName, addProperties, options, isSync, direction, stdioState, verboseInfo, outputLines}); return {fdNumber, direction, outputLines, stdioItems: normalizedStdioItems};};
const getOptionName = fdNumber => KNOWN_OPTION_NAMES[fdNumber] ?? `stdio[${fdNumber}]`;const KNOWN_OPTION_NAMES = ['stdin', 'stdout', 'stderr'];
const initializeStdioItems = (stdioOption, fdNumber, options, optionName) => {const initializeStdioItems = ({stdioOption, fdNumber, options, isSync, optionName}) => { const values = Array.isArray(stdioOption) ? stdioOption : [stdioOption]; const initialStdioItems = [ ...values.map(value => initializeStdioItem(value, optionName)), ...handleInputOptions(options, fdNumber),2 unmodified lines const stdioItems = filterDuplicates(initialStdioItems); const isStdioArray = stdioItems.length > 1; validateStdioArray(stdioItems, isStdioArray, optionName); validateStreams(stdioItems); return stdioItems.map(stdioItem => handleNativeStream(stdioItem, isStdioArray, fdNumber)); return stdioItems.map(stdioItem => handleNativeStream(stdioItem, isStdioArray, fdNumber, isSync));};
const initializeStdioItem = (value, optionName) => ({ type: getStdioItemType(value, optionName),72 unmodified linesmodified:lib/stdio/native.js+2 added-2 removed
6 unmodified lines789101111121314141516171828 unmodified lines6 unmodified lines// - Node.js streams are marked as `type: nodeStream`// - 'inherit' becomes `process.stdin|stdout|stderr`// - any file descriptor integer becomes `process.stdio[fdNumber]`// All of the above transformations tell Execa to perform manual piping.export const handleNativeStream = (stdioItem, isStdioArray, fdNumber) => {export const handleNativeStream = (stdioItem, isStdioArray, fdNumber, isSync) => { const {type, value, optionName} = stdioItem;
if (!isStdioArray || type !== 'native') { if (!isStdioArray || type !== 'native' || isSync) { return stdioItem; }
if (value === 'inherit') {28 unmodified linesmodified:lib/stdio/sync.js+69 added-8 removed
1 import {readFileSync, writeFileSync} from 'node:fs';2+import {isStream as isNodeStream} from 'is-stream';3 import {bufferToUint8Array, uint8ArrayToString} from '../utils.js';4 import {handleInput} from './handle.js';5 import {TYPE_TO_MESSAGE} from './type.js';6 7 // Handle `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, before spawning, in sync mode8 export const handleInputSync = (options, verboseInfo) => {9 const {fileDescriptors} = handleInput(addPropertiesSync, options, verboseInfo, true);10+ validateStdioArraysSync(fileDescriptors);9- addInputOptionSync(fileDescriptors, options);11+ addInputOptionsSync(fileDescriptors, options);12 return fileDescriptors;13 };14 15 const forbiddenIfSync = ({type, optionName}) => {8 unmodified lines24 return {};25 };26 27 const throwInvalidSyncValue = (optionName, value) => {26- throw new TypeError(`The \`${optionName}\` option cannot be ${value} in sync mode.`);28+ throw new TypeError(`The \`${optionName}\` option cannot be ${value} with synchronous methods.`);29 };30 31 const addProperties = {32 generator: forbiddenIfSync,21 unmodified lines54 uint8Array: forbiddenIfSync,55 },56 };57 58+const validateStdioArraysSync = fileDescriptors => {59+ for (const {stdioItems} of fileDescriptors) {60+ validateStdioArraySync(stdioItems);61+ }62+};63+64+const validateStdioArraySync = stdioItems => {65+ if (stdioItems.length === 1) {66+ return;67+ }68+69+ const singleValueName = stdioItems.map(stdioItem => getSingleValueSync(stdioItem)).find(Boolean);70+ if (singleValueName === undefined) {71+ return;72+ }73+74+ const inputOption = stdioItems.find(({optionName}) => OPTION_NAMES.has(optionName));75+ if (inputOption !== undefined) {76+ throw new TypeError(`The \`${singleValueName}\` and the \`${inputOption.optionName}\` options cannot be both set with synchronous methods.`);77+ }78+79+ throw new TypeError(`The \`${singleValueName}\` option cannot be set as an array of values with synchronous methods.`);80+};81+82+const getSingleValueSync = ({type, value, optionName}) => {83+ if (type !== 'native') {84+ return;85+ }86+87+ if (value === 'inherit') {88+ return `${optionName}: "inherit"`;89+ }90+91+ if (typeof value === 'number') {92+ return `${optionName}: ${value}`;93+ }94+95+ if (isNodeStream(value, {checkOpen: false})) {96+ return `${optionName}: Stream`;97+ }98+};99+100+const OPTION_NAMES = new Set(['input', 'inputFile']);101+102+const addInputOptionsSync = (fileDescriptors, options) => {103+ for (const fdNumber of getInputFdNumbers(fileDescriptors)) {104+ addInputOptionSync(fileDescriptors, fdNumber, options);105+ }106+};107+108+const getInputFdNumbers = fileDescriptors => new Set(fileDescriptors109+ .filter(({direction}) => direction === 'input')110+ .map(({fdNumber}) => fdNumber));111+56-const addInputOptionSync = (fileDescriptors, options) => {57- const allContents = fileDescriptors58- .filter(({direction}) => direction === 'input')112+const addInputOptionSync = (fileDescriptors, fdNumber, options) => {113+ const allStdioItems = fileDescriptors114+ .filter(fileDescriptor => fileDescriptor.fdNumber === fdNumber)115 .flatMap(({stdioItems}) => stdioItems)60- .map(({contents}) => contents)61- .filter(contents => contents !== undefined);62- if (allContents.length === 0) {116+ .filter(({contents}) => contents !== undefined);117+ if (allStdioItems.length === 0) {118 return;119 }120 121+ if (fdNumber !== 0) {122+ const [{type, optionName}] = allStdioItems;123+ throw new TypeError(`Only the \`stdin\` option, not \`${optionName}\`, can be ${TYPE_TO_MESSAGE[type]} with synchronous methods.`);124+ }125+126+ const allContents = allStdioItems.map(({contents}) => contents);127 options.input = allContents.length === 1128 ? allContents[0]129 : allContents.map(contents => serializeContents(contents)).join('');130 };25 unmodified linesmodified:test/stdio/file-path.js+38 added-16 removed
6 unmodified lines7 import {execa, execaSync} from '../../index.js';8 import {setFixtureDir} from '../helpers/fixtures-dir.js';9 import {identity, getStdio} from '../helpers/stdio.js';10 import {runExeca, runExecaSync, runScript, runScriptSync} from '../helpers/run.js';11-import {foobarUint8Array} from '../helpers/input.js';11+import {foobarString, foobarUint8Array} from '../helpers/input.js';12 13 setFixtureDir();14 15 const nonFileUrl = new URL('https://example.com');16 17 const getAbsolutePath = file => ({file});18 const getRelativePath = filePath => ({file: relative('.', filePath)});19 20-const getStdioFile = (fdNumber, file) => getStdio(fdNumber, fdNumber === 0 ? {file} : file);21-20 const getStdioInput = (fdNumberOrName, file) => {21 if (fdNumberOrName === 'string') {24- return {input: 'foobar'};22+ return {input: foobarString};23 }24 25 if (fdNumberOrName === 'binary') {26 return {input: foobarUint8Array};27 }28 31- return getStdioFile(fdNumberOrName, file);29+ return getStdioInputFile(fdNumberOrName, file);30 };31 32+const getStdioInputFile = (fdNumberOrName, file) => getStdio(fdNumberOrName, typeof fdNumberOrName === 'string' ? file : {file});33+34 const testStdinFile = async (t, mapFilePath, fdNumber, execaMethod) => {35 const filePath = tempfile();36- await writeFile(filePath, 'foobar');36+ await writeFile(filePath, foobarString);37 const {stdout} = await execaMethod('stdin.js', getStdio(fdNumber, mapFilePath(filePath)));38- t.is(stdout, 'foobar');38+ t.is(stdout, foobarString);39 await rm(filePath);40 };41 42 test('inputFile can be a file URL', testStdinFile, pathToFileURL, 'inputFile', execa);10 unmodified lines53 test('stdin can be a relative file path - sync', testStdinFile, getRelativePath, 0, execaSync);54 55 const testOutputFile = async (t, mapFile, fdNumber, execaMethod) => {56 const filePath = tempfile();57- await execaMethod('noop-fd.js', [`${fdNumber}`, 'foobar'], getStdio(fdNumber, mapFile(filePath)));58- t.is(await readFile(filePath, 'utf8'), 'foobar');57+ await execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, mapFile(filePath)));58+ t.is(await readFile(filePath, 'utf8'), foobarString);59 await rm(filePath);60 };61 62 test('stdout can be a file URL', testOutputFile, pathToFileURL, 1, execa);42 unmodified lines105 test('inputFile must be a file URL or string - sync', testInvalidInputFile, execaSync);106 107 const testInputFileValidUrl = async (t, fdNumber, execaMethod) => {108 const filePath = tempfile();109- await writeFile(filePath, 'foobar');109+ await writeFile(filePath, foobarString);110 const currentCwd = process.cwd();111 process.chdir(dirname(filePath));112 113 try {114- const {stdout} = await execaMethod('stdin.js', getStdioFile(fdNumber, basename(filePath)));115- t.is(stdout, 'foobar');114+ const {stdout} = await execaMethod('stdin.js', getStdioInputFile(fdNumber, basename(filePath)));115+ t.is(stdout, foobarString);116 } finally {117 process.chdir(currentCwd);118 await rm(filePath);119 }5 unmodified lines125 test.serial('stdin does not need to start with . when being a relative file path - sync', testInputFileValidUrl, 0, execaSync);126 127 const testFilePathObject = (t, fdNumber, execaMethod) => {128 t.throws(() => {129- execaMethod('empty.js', getStdio(fdNumber, 'foobar'));129+ execaMethod('empty.js', getStdio(fdNumber, foobarString));130 }, {message: /must be used/});131 };132 133 test('stdin must be an object when it is a file path string', testFilePathObject, 0, execa);41 unmodified lines175 test('stdio[*] file path errors should be handled - sync', testFileErrorSync, getAbsolutePath, 3);176 177 const testMultipleInputs = async (t, indices, execaMethod) => {178 const filePath = tempfile();179- await writeFile(filePath, 'foobar');179+ await writeFile(filePath, foobarString);180 const options = Object.assign({}, ...indices.map(fdNumber => getStdioInput(fdNumber, filePath)));181 const {stdout} = await execaMethod('stdin.js', options);182- t.is(stdout, 'foobar'.repeat(indices.length));182+ t.is(stdout, foobarString.repeat(indices.length));183 await rm(filePath);184 };185 186 test('inputFile can be set', testMultipleInputs, ['inputFile'], runExeca);14 unmodified lines201 test('stdin and inputFile can be both set - sync', testMultipleInputs, [0, 'inputFile'], execaSync);202 test('input String, stdin and inputFile can be all set - sync', testMultipleInputs, ['inputFile', 0, 'string'], execaSync);203 test('input Uint8Array, stdin and inputFile can be all set - sync', testMultipleInputs, ['inputFile', 0, 'binary'], execaSync);204 205+const testMultipleOutputs = async (t, mapFile, fdNumber, execaMethod) => {206+ const filePath = tempfile();207+ const filePathTwo = tempfile();208+ await execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, [mapFile(filePath), mapFile(filePathTwo)]));209+ t.is(await readFile(filePath, 'utf8'), foobarString);210+ t.is(await readFile(filePathTwo, 'utf8'), foobarString);211+ await Promise.all([rm(filePath), rm(filePathTwo)]);212+};213+214+test('stdout can be two file URLs', testMultipleOutputs, pathToFileURL, 1, execa);215+test('stdout can be two file paths', testMultipleOutputs, getAbsolutePath, 1, execa);216+test('stdout can be two file URLs - sync', testMultipleOutputs, pathToFileURL, 1, execaSync);217+test('stdout can be two file paths - sync', testMultipleOutputs, getAbsolutePath, 1, execaSync);218+test('stderr can be two file URLs', testMultipleOutputs, pathToFileURL, 2, execa);219+test('stderr can be two file paths', testMultipleOutputs, getAbsolutePath, 2, execa);220+test('stderr can be two file URLs - sync', testMultipleOutputs, pathToFileURL, 2, execaSync);221+test('stderr can be two file paths - sync', testMultipleOutputs, getAbsolutePath, 2, execaSync);222+test('stdio[*] can be two file URLs', testMultipleOutputs, pathToFileURL, 3, execa);223+test('stdio[*] can be two file paths', testMultipleOutputs, getAbsolutePath, 3, execa);224+test('stdio[*] can be two file URLs - sync', testMultipleOutputs, pathToFileURL, 3, execaSync);225+test('stdio[*] can be two file paths - sync', testMultipleOutputs, getAbsolutePath, 3, execaSync);226+227 const testInputFileHanging = async (t, mapFilePath) => {228 const filePath = tempfile();207- await writeFile(filePath, 'foobar');229+ await writeFile(filePath, foobarString);230 await t.throwsAsync(execa('stdin.js', {stdin: mapFilePath(filePath), timeout: 1}), {message: /timed out/});231 await rm(filePath);232 };233 2 unmodified linesmodified:test/stdio/handle.js+1 added-1 removed
64 unmodified lines65 66 const testNoIpcSync = (t, fdNumber) => {67 t.throws(() => {68 execaSync('empty.js', getStdio(fdNumber, 'ipc'));69- }, {message: /cannot be "ipc" in sync mode/});69+ }, {message: /cannot be "ipc" with synchronous methods/});70 };71 72 test('stdin cannot be "ipc", sync', testNoIpcSync, 0);73 test('stdout cannot be "ipc", sync', testNoIpcSync, 1);25 unmodified linesmodified:test/stdio/iterable.js+1 added-1 removed
66 unmodified lines67 68 const testIterableSync = (t, stdioOption, fdNumber) => {69 t.throws(() => {70 execaSync('empty.js', getStdio(fdNumber, stdioOption));71- }, {message: /an iterable in sync mode/});71+ }, {message: /an iterable with synchronous methods/});72 };73 74 test('stdin option cannot be an array of strings - sync', testIterableSync, [stringArray], 0);75 test('stdio[*] option cannot be an array of strings - sync', testIterableSync, [stringArray], 3);52 unmodified linesmodified:test/stdio/node-stream.js+1 added-1 removed
37 unmodified lines38 39 test('input cannot be a Node.js Readable without a file descriptor - sync', t => {40 t.throws(() => {41 execaSync('empty.js', {input: simpleReadable()});42- }, {message: 'The `input` option cannot be a Node.js stream in sync mode.'});42+ }, {message: 'The `input` option cannot be a Node.js stream with synchronous methods.'});43 });44 45 const testNoFileStream = async (t, fdNumber, stream) => {46 await t.throwsAsync(execa('empty.js', getStdio(fdNumber, stream)), {code: 'ERR_INVALID_ARG_VALUE'});262 unmodified linesadded:test/stdio/sync.js+57 added
1+import {fileURLToPath} from 'node:url';2+import process from 'node:process';3+import test from 'ava';4+import {execaSync} from '../../index.js';5+import {setFixtureDir} from '../helpers/fixtures-dir.js';6+import {getStdio} from '../helpers/stdio.js';7+import {noopReadable, noopWritable} from '../helpers/stream.js';8+9+setFixtureDir();10+11+const getArrayMessage = singleValueName => `The \`${singleValueName}\` option cannot be set as an array`;12+const getInputMessage = (singleValueName, inputName) => `The \`${singleValueName}\` and the \`${inputName}\` options cannot be both set`;13+const getFd3InputMessage = type => `not \`stdio[3]\`, can be ${type}`;14+15+const inputOptions = {input: ''};16+const inputFileOptions = {inputFile: fileURLToPath(import.meta.url)};17+18+// eslint-disable-next-line max-params19+const testInvalidStdioArraySync = (t, fdNumber, stdioOption, options, expectedMessage) => {20+ const {message} = t.throws(() => {21+ execaSync('empty.js', {...getStdio(fdNumber, stdioOption), ...options});22+ });23+ t.true(message.includes(expectedMessage));24+};25+26+test('Cannot use ["inherit", "pipe"] with stdin, sync', testInvalidStdioArraySync, 0, ['inherit', 'pipe'], {}, getArrayMessage('stdin: "inherit"'));27+test('Cannot use [0, "pipe"] with stdin, sync', testInvalidStdioArraySync, 0, [0, 'pipe'], {}, getArrayMessage('stdin: 0'));28+test('Cannot use [process.stdin, "pipe"] with stdin, sync', testInvalidStdioArraySync, 0, [process.stdin, 'pipe'], {}, getArrayMessage('stdin: Stream'));29+test('Cannot use [Readable, "pipe"] with stdin, sync', testInvalidStdioArraySync, 0, [noopReadable(), 'pipe'], {}, getArrayMessage('stdin: Stream'));30+test('Cannot use "inherit" + "input" with stdin, sync', testInvalidStdioArraySync, 0, 'inherit', inputOptions, getInputMessage('stdin: "inherit"', 'input'));31+test('Cannot use 0 + "input" with stdin, sync', testInvalidStdioArraySync, 0, 0, inputOptions, getInputMessage('stdin: 0', 'input'));32+test('Cannot use process.stdin + "input" with stdin, sync', testInvalidStdioArraySync, 0, process.stdin, inputOptions, getInputMessage('stdin: Stream', 'input'));33+test('Cannot use Readable + "input" with stdin, sync', testInvalidStdioArraySync, 0, noopReadable(), inputOptions, getInputMessage('stdin: Stream', 'input'));34+test('Cannot use "inherit" + "inputFile" with stdin, sync', testInvalidStdioArraySync, 0, 'inherit', inputFileOptions, getInputMessage('stdin: "inherit"', 'inputFile'));35+test('Cannot use 0 + "inputFile" with stdin, sync', testInvalidStdioArraySync, 0, 0, inputFileOptions, getInputMessage('stdin: 0', 'inputFile'));36+test('Cannot use process.stdin + "inputFile" with stdin, sync', testInvalidStdioArraySync, 0, process.stdin, inputFileOptions, getInputMessage('stdin: Stream', 'inputFile'));37+test('Cannot use Readable + "inputFile" with stdin, sync', testInvalidStdioArraySync, 0, noopReadable(), inputFileOptions, getInputMessage('stdin: Stream', 'inputFile'));38+test('Cannot use ["inherit", "pipe"] with stdout, sync', testInvalidStdioArraySync, 1, ['inherit', 'pipe'], {}, getArrayMessage('stdout: "inherit"'));39+test('Cannot use [1, "pipe"] with stdout, sync', testInvalidStdioArraySync, 1, [1, 'pipe'], {}, getArrayMessage('stdout: 1'));40+test('Cannot use [process.stdout, "pipe"] with stdout, sync', testInvalidStdioArraySync, 1, [process.stdout, 'pipe'], {}, getArrayMessage('stdout: Stream'));41+test('Cannot use [Writable, "pipe"] with stdout, sync', testInvalidStdioArraySync, 1, [noopWritable(), 'pipe'], {}, getArrayMessage('stdout: Stream'));42+test('Cannot use ["inherit", "pipe"] with stderr, sync', testInvalidStdioArraySync, 2, ['inherit', 'pipe'], {}, getArrayMessage('stderr: "inherit"'));43+test('Cannot use [2, "pipe"] with stderr, sync', testInvalidStdioArraySync, 2, [2, 'pipe'], {}, getArrayMessage('stderr: 2'));44+test('Cannot use [process.stderr, "pipe"] with stderr, sync', testInvalidStdioArraySync, 2, [process.stderr, 'pipe'], {}, getArrayMessage('stderr: Stream'));45+test('Cannot use [Writable, "pipe"] with stderr, sync', testInvalidStdioArraySync, 2, [noopWritable(), 'pipe'], {}, getArrayMessage('stderr: Stream'));46+test('Cannot use ["inherit", "pipe"] with stdio[*], sync', testInvalidStdioArraySync, 3, ['inherit', 'pipe'], {}, getArrayMessage('stdio[3]: "inherit"'));47+test('Cannot use [3, "pipe"] with stdio[*], sync', testInvalidStdioArraySync, 3, [3, 'pipe'], {}, getArrayMessage('stdio[3]: 3'));48+test('Cannot use [Writable, "pipe"] with stdio[*], sync', testInvalidStdioArraySync, 3, [noopWritable(), 'pipe'], {}, getArrayMessage('stdio[3]: Stream'));49+50+const testFd3InputSync = (t, stdioOption, expectedMessage) => {51+ const {message} = t.throws(() => {52+ execaSync('empty.js', getStdio(3, stdioOption));53+ });54+ t.true(message.includes(expectedMessage));55+};56+57+test('Cannot use Uint8Array with stdio[*], sync', testFd3InputSync, new Uint8Array(), getFd3InputMessage('a Uint8Array'));modified:test/stdio/web-stream.js+1 added-1 removed
32 unmodified lines33 34 const testWebStreamSync = (t, StreamClass, fdNumber, optionName) => {35 t.throws(() => {36 execaSync('empty.js', getStdio(fdNumber, new StreamClass()));37- }, {message: `The \`${optionName}\` option cannot be a web stream in sync mode.`});37+ }, {message: `The \`${optionName}\` option cannot be a web stream with synchronous methods.`});38 };39 40 test('stdin cannot be a ReadableStream - sync', testWebStreamSync, ReadableStream, 0, 'stdin');41 test('stdio[*] cannot be a ReadableStream - sync', testWebStreamSync, ReadableStream, 3, 'stdio[3]');57 unmodified linesmodified:index.d.ts+2 added-2 removed
1381 unmodified lines1382 Same as `execa()` but synchronous.1383 1384 Returns or throws a `subprocessResult`. The `subprocess` 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()`, `.iterable()`, `.readable()`, `.writable()`, `.duplex()` and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.1385 1386-Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `ipc`, `serialization`, `cancelSignal`, `forceKillAfterDelay`, `lines` and `verbose: 'full'`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, [`overlapped`](https://nodejs.org/api/child_process.html#optionsstdio), an iterable, a transform, a `Duplex`, or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1386+Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `ipc`, `serialization`, `cancelSignal`, `forceKillAfterDelay`, `lines` and `verbose: 'full'`. Also, the `stdin`, `stdout`, `stderr` and `stdio` options cannot be a `['pipe', 'inherit']` array, [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an iterable, a transform, a `Duplex`, or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1387 1388 @param file - The program/script to execute, as a string or file URL1389 @param arguments - Arguments to pass to `file` on execution.1390 @returns A `subprocessResult` object105 unmodified lines1496 Same as `execaCommand()` but synchronous.1497 1498 Returns or throws a `subprocessResult`. The `subprocess` 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()`, `.iterable()`, `.readable()`, `.writable()`, `.duplex()` and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.1499 1500-Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `ipc`, `serialization`, `cancelSignal`, `forceKillAfterDelay`, `lines` and `verbose: 'full'`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, [`overlapped`](https://nodejs.org/api/child_process.html#optionsstdio), an iterable, a transform, a `Duplex`, or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1500+Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `ipc`, `serialization`, `cancelSignal`, `forceKillAfterDelay`, `lines` and `verbose: 'full'`. Also, the `stdin`, `stdout`, `stderr` and `stdio` options cannot be a `['pipe', 'inherit']` array, [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an iterable, a transform, a `Duplex`, or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1501 1502 @param command - The program/script to execute and its arguments.1503 @returns A `subprocessResult` object1504 @throws A `subprocessResult` error128 unmodified linesmodified:readme.md+1 added-1 removed
317 unmodified lines318 Same as [`execa()`](#execafile-arguments-options) but synchronous.319 320 Returns or throws a [`subprocessResult`](#subprocessResult). The [`subprocess`](#subprocess) 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()`](#pipefile-arguments-options), [`.iterable()`](#iterablereadableoptions), [`.readable()`](#readablereadableoptions), [`.writable()`](#writablewritableoptions), [`.duplex()`](#duplexduplexoptions) and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.321 322-Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`ipc`](#ipc), [`serialization`](#serialization), [`cancelSignal`](#cancelsignal), [`forceKillAfterDelay`](#forcekillafterdelay), [`lines`](#lines) and [`verbose: 'full'`](#verbose). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be an array, [`overlapped`](https://nodejs.org/api/child_process.html#optionsstdio), an iterable, a [transform](docs/transform.md), a [`Duplex`](docs/transform.md#duplextransform-streams), or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.322+Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`ipc`](#ipc), [`serialization`](#serialization), [`cancelSignal`](#cancelsignal), [`forceKillAfterDelay`](#forcekillafterdelay), [`lines`](#lines) and [`verbose: 'full'`](#verbose). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1) and [`stdio`](#stdio-1) cannot be a [`['pipe', 'inherit']`](#redirect-stdinstdoutstderr-to-multiple-destinations) array, [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an iterable, a [transform](docs/transform.md), a [`Duplex`](docs/transform.md#duplextransform-streams), or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.323 324 #### $(file, arguments?, options?)325 326 `file`: `string | URL`\899 unmodified lines