Skip to content
Myr

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

11 files+176 added−36 removed

modified:lib/stdio/handle.js+3 added-3 removed
modified:lib/stdio/native.js+2 added-2 removed
modified:lib/stdio/sync.js+69 added-8 removed
1import {readFileSync, writeFileSync} from 'node:fs';2import {isStream as isNodeStream} from 'is-stream';3import {bufferToUint8Array, uint8ArrayToString} from '../utils.js';4import {handleInput} from './handle.js';5import {TYPE_TO_MESSAGE} from './type.js';67// Handle `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, before spawning, in sync mode8export 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};1415const forbiddenIfSync = ({type, optionName}) => {
8 unmodified lines
24 return {};25};2627const 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};3031const addProperties = {32 generator: forbiddenIfSync,
21 unmodified lines
54 uint8Array: forbiddenIfSync,55 },56};5758const validateStdioArraysSync = fileDescriptors => {59 for (const {stdioItems} of fileDescriptors) {60 validateStdioArraySync(stdioItems);61 }62};6364const validateStdioArraySync = stdioItems => {65 if (stdioItems.length === 1) {66 return;67 }6869 const singleValueName = stdioItems.map(stdioItem => getSingleValueSync(stdioItem)).find(Boolean);70 if (singleValueName === undefined) {71 return;72 }7374 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 }7879 throw new TypeError(`The \`${singleValueName}\` option cannot be set as an array of values with synchronous methods.`);80};8182const getSingleValueSync = ({type, value, optionName}) => {83 if (type !== 'native') {84 return;85 }8687 if (value === 'inherit') {88 return `${optionName}: "inherit"`;89 }9091 if (typeof value === 'number') {92 return `${optionName}: ${value}`;93 }9495 if (isNodeStream(value, {checkOpen: false})) {96 return `${optionName}: Stream`;97 }98};99100const OPTION_NAMES = new Set(['input', 'inputFile']);101102const addInputOptionsSync = (fileDescriptors, options) => {103 for (const fdNumber of getInputFdNumbers(fileDescriptors)) {104 addInputOptionSync(fileDescriptors, fdNumber, options);105 }106};107108const getInputFdNumbers = fileDescriptors => new Set(fileDescriptors109 .filter(({direction}) => direction === 'input')110 .map(({fdNumber}) => fdNumber));11156const addInputOptionSync = (fileDescriptors, options) => {57 const allContents = fileDescriptors58 .filter(({direction}) => direction === 'input')112const 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 }120121 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 }125126 const allContents = allStdioItems.map(({contents}) => contents);127 options.input = allContents.length === 1128 ? allContents[0]129 : allContents.map(contents => serializeContents(contents)).join('');130};
25 unmodified lines
modified:test/stdio/file-path.js+38 added-16 removed
6 unmodified lines
7import {execa, execaSync} from '../../index.js';8import {setFixtureDir} from '../helpers/fixtures-dir.js';9import {identity, getStdio} from '../helpers/stdio.js';10import {runExeca, runExecaSync, runScript, runScriptSync} from '../helpers/run.js';11import {foobarUint8Array} from '../helpers/input.js';11import {foobarString, foobarUint8Array} from '../helpers/input.js';1213setFixtureDir();1415const nonFileUrl = new URL('https://example.com');1617const getAbsolutePath = file => ({file});18const getRelativePath = filePath => ({file: relative('.', filePath)});1920const getStdioFile = (fdNumber, file) => getStdio(fdNumber, fdNumber === 0 ? {file} : file);2120const getStdioInput = (fdNumberOrName, file) => {21 if (fdNumberOrName === 'string') {24 return {input: 'foobar'};22 return {input: foobarString};23 }2425 if (fdNumberOrName === 'binary') {26 return {input: foobarUint8Array};27 }2831 return getStdioFile(fdNumberOrName, file);29 return getStdioInputFile(fdNumberOrName, file);30};3132const getStdioInputFile = (fdNumberOrName, file) => getStdio(fdNumberOrName, typeof fdNumberOrName === 'string' ? file : {file});3334const 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};4142test('inputFile can be a file URL', testStdinFile, pathToFileURL, 'inputFile', execa);
10 unmodified lines
53test('stdin can be a relative file path - sync', testStdinFile, getRelativePath, 0, execaSync);5455const 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};6162test('stdout can be a file URL', testOutputFile, pathToFileURL, 1, execa);
42 unmodified lines
105test('inputFile must be a file URL or string - sync', testInvalidInputFile, execaSync);106107const 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));112113 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 lines
125test.serial('stdin does not need to start with . when being a relative file path - sync', testInputFileValidUrl, 0, execaSync);126127const 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};132133test('stdin must be an object when it is a file path string', testFilePathObject, 0, execa);
41 unmodified lines
175test('stdio[*] file path errors should be handled - sync', testFileErrorSync, getAbsolutePath, 3);176177const 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};185186test('inputFile can be set', testMultipleInputs, ['inputFile'], runExeca);
14 unmodified lines
201test('stdin and inputFile can be both set - sync', testMultipleInputs, [0, 'inputFile'], execaSync);202test('input String, stdin and inputFile can be all set - sync', testMultipleInputs, ['inputFile', 0, 'string'], execaSync);203test('input Uint8Array, stdin and inputFile can be all set - sync', testMultipleInputs, ['inputFile', 0, 'binary'], execaSync);204205const 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};213214test('stdout can be two file URLs', testMultipleOutputs, pathToFileURL, 1, execa);215test('stdout can be two file paths', testMultipleOutputs, getAbsolutePath, 1, execa);216test('stdout can be two file URLs - sync', testMultipleOutputs, pathToFileURL, 1, execaSync);217test('stdout can be two file paths - sync', testMultipleOutputs, getAbsolutePath, 1, execaSync);218test('stderr can be two file URLs', testMultipleOutputs, pathToFileURL, 2, execa);219test('stderr can be two file paths', testMultipleOutputs, getAbsolutePath, 2, execa);220test('stderr can be two file URLs - sync', testMultipleOutputs, pathToFileURL, 2, execaSync);221test('stderr can be two file paths - sync', testMultipleOutputs, getAbsolutePath, 2, execaSync);222test('stdio[*] can be two file URLs', testMultipleOutputs, pathToFileURL, 3, execa);223test('stdio[*] can be two file paths', testMultipleOutputs, getAbsolutePath, 3, execa);224test('stdio[*] can be two file URLs - sync', testMultipleOutputs, pathToFileURL, 3, execaSync);225test('stdio[*] can be two file paths - sync', testMultipleOutputs, getAbsolutePath, 3, execaSync);226227const 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 lines
modified:test/stdio/handle.js+1 added-1 removed
64 unmodified lines
6566const 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};7172test('stdin cannot be "ipc", sync', testNoIpcSync, 0);73test('stdout cannot be "ipc", sync', testNoIpcSync, 1);
25 unmodified lines
modified:test/stdio/iterable.js+1 added-1 removed
66 unmodified lines
6768const 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};7374test('stdin option cannot be an array of strings - sync', testIterableSync, [stringArray], 0);75test('stdio[*] option cannot be an array of strings - sync', testIterableSync, [stringArray], 3);
52 unmodified lines
modified:test/stdio/node-stream.js+1 added-1 removed
37 unmodified lines
3839test('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});4445const testNoFileStream = async (t, fdNumber, stream) => {46 await t.throwsAsync(execa('empty.js', getStdio(fdNumber, stream)), {code: 'ERR_INVALID_ARG_VALUE'});
262 unmodified lines
added:test/stdio/sync.js+57 added
1import {fileURLToPath} from 'node:url';2import process from 'node:process';3import test from 'ava';4import {execaSync} from '../../index.js';5import {setFixtureDir} from '../helpers/fixtures-dir.js';6import {getStdio} from '../helpers/stdio.js';7import {noopReadable, noopWritable} from '../helpers/stream.js';89setFixtureDir();1011const getArrayMessage = singleValueName => `The \`${singleValueName}\` option cannot be set as an array`;12const getInputMessage = (singleValueName, inputName) => `The \`${singleValueName}\` and the \`${inputName}\` options cannot be both set`;13const getFd3InputMessage = type => `not \`stdio[3]\`, can be ${type}`;1415const inputOptions = {input: ''};16const inputFileOptions = {inputFile: fileURLToPath(import.meta.url)};1718// eslint-disable-next-line max-params19const 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};2526test('Cannot use ["inherit", "pipe"] with stdin, sync', testInvalidStdioArraySync, 0, ['inherit', 'pipe'], {}, getArrayMessage('stdin: "inherit"'));27test('Cannot use [0, "pipe"] with stdin, sync', testInvalidStdioArraySync, 0, [0, 'pipe'], {}, getArrayMessage('stdin: 0'));28test('Cannot use [process.stdin, "pipe"] with stdin, sync', testInvalidStdioArraySync, 0, [process.stdin, 'pipe'], {}, getArrayMessage('stdin: Stream'));29test('Cannot use [Readable, "pipe"] with stdin, sync', testInvalidStdioArraySync, 0, [noopReadable(), 'pipe'], {}, getArrayMessage('stdin: Stream'));30test('Cannot use "inherit" + "input" with stdin, sync', testInvalidStdioArraySync, 0, 'inherit', inputOptions, getInputMessage('stdin: "inherit"', 'input'));31test('Cannot use 0 + "input" with stdin, sync', testInvalidStdioArraySync, 0, 0, inputOptions, getInputMessage('stdin: 0', 'input'));32test('Cannot use process.stdin + "input" with stdin, sync', testInvalidStdioArraySync, 0, process.stdin, inputOptions, getInputMessage('stdin: Stream', 'input'));33test('Cannot use Readable + "input" with stdin, sync', testInvalidStdioArraySync, 0, noopReadable(), inputOptions, getInputMessage('stdin: Stream', 'input'));34test('Cannot use "inherit" + "inputFile" with stdin, sync', testInvalidStdioArraySync, 0, 'inherit', inputFileOptions, getInputMessage('stdin: "inherit"', 'inputFile'));35test('Cannot use 0 + "inputFile" with stdin, sync', testInvalidStdioArraySync, 0, 0, inputFileOptions, getInputMessage('stdin: 0', 'inputFile'));36test('Cannot use process.stdin + "inputFile" with stdin, sync', testInvalidStdioArraySync, 0, process.stdin, inputFileOptions, getInputMessage('stdin: Stream', 'inputFile'));37test('Cannot use Readable + "inputFile" with stdin, sync', testInvalidStdioArraySync, 0, noopReadable(), inputFileOptions, getInputMessage('stdin: Stream', 'inputFile'));38test('Cannot use ["inherit", "pipe"] with stdout, sync', testInvalidStdioArraySync, 1, ['inherit', 'pipe'], {}, getArrayMessage('stdout: "inherit"'));39test('Cannot use [1, "pipe"] with stdout, sync', testInvalidStdioArraySync, 1, [1, 'pipe'], {}, getArrayMessage('stdout: 1'));40test('Cannot use [process.stdout, "pipe"] with stdout, sync', testInvalidStdioArraySync, 1, [process.stdout, 'pipe'], {}, getArrayMessage('stdout: Stream'));41test('Cannot use [Writable, "pipe"] with stdout, sync', testInvalidStdioArraySync, 1, [noopWritable(), 'pipe'], {}, getArrayMessage('stdout: Stream'));42test('Cannot use ["inherit", "pipe"] with stderr, sync', testInvalidStdioArraySync, 2, ['inherit', 'pipe'], {}, getArrayMessage('stderr: "inherit"'));43test('Cannot use [2, "pipe"] with stderr, sync', testInvalidStdioArraySync, 2, [2, 'pipe'], {}, getArrayMessage('stderr: 2'));44test('Cannot use [process.stderr, "pipe"] with stderr, sync', testInvalidStdioArraySync, 2, [process.stderr, 'pipe'], {}, getArrayMessage('stderr: Stream'));45test('Cannot use [Writable, "pipe"] with stderr, sync', testInvalidStdioArraySync, 2, [noopWritable(), 'pipe'], {}, getArrayMessage('stderr: Stream'));46test('Cannot use ["inherit", "pipe"] with stdio[*], sync', testInvalidStdioArraySync, 3, ['inherit', 'pipe'], {}, getArrayMessage('stdio[3]: "inherit"'));47test('Cannot use [3, "pipe"] with stdio[*], sync', testInvalidStdioArraySync, 3, [3, 'pipe'], {}, getArrayMessage('stdio[3]: 3'));48test('Cannot use [Writable, "pipe"] with stdio[*], sync', testInvalidStdioArraySync, 3, [noopWritable(), 'pipe'], {}, getArrayMessage('stdio[3]: Stream'));4950const testFd3InputSync = (t, stdioOption, expectedMessage) => {51 const {message} = t.throws(() => {52 execaSync('empty.js', getStdio(3, stdioOption));53 });54 t.true(message.includes(expectedMessage));55};5657test('Cannot use Uint8Array with stdio[*], sync', testFd3InputSync, new Uint8Array(), getFd3InputMessage('a Uint8Array'));
modified:test/stdio/web-stream.js+1 added-1 removed
32 unmodified lines
3334const 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};3940test('stdin cannot be a ReadableStream - sync', testWebStreamSync, ReadableStream, 0, 'stdin');41test('stdio[*] cannot be a ReadableStream - sync', testWebStreamSync, ReadableStream, 3, 'stdio[3]');
57 unmodified lines
modified:index.d.ts+2 added-2 removed
1381 unmodified lines
1382Same as `execa()` but synchronous.13831384Returns 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.13851386Cannot 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.1386Cannot 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.13871388@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` object
105 unmodified lines
1496Same as `execaCommand()` but synchronous.14971498Returns 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.14991500Cannot 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.1500Cannot 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.15011502@param command - The program/script to execute and its arguments.1503@returns A `subprocessResult` object1504@throws A `subprocessResult` error
128 unmodified lines
modified:readme.md+1 added-1 removed
317 unmodified lines
318Same as [`execa()`](#execafile-arguments-options) but synchronous.319320Returns 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.321322Cannot 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.322Cannot 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.323324#### $(file, arguments?, options?)325326`file`: `string | URL`\
899 unmodified lines