Allow Node.js streams with synchronous methods (#708)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent 67b476b · Browse files · 6 files·+84 added−75 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+84 added−75 removed
- tests:+29 added−19 removed
- other:+55 added−56 removed
Provenance
- Commit
86bdadf- Tree
22e3176- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
67b476b
6 files changed+84 added−75 removed
modified:lib/stdio/sync.js+1 added-12 removed
1223453 unmodified lines91011121415161718192021131415164 unmodified lines21222324342526272829303132433334353648373839404129 unmodified linesimport {readFileSync, writeFileSync} from 'node:fs';import {isStream as isNodeStream} from 'is-stream';import {handleInput} from './handle.js';import {TYPE_TO_MESSAGE} from './type.js';import {bufferToUint8Array} from './utils.js';
3 unmodified lines addInputOptionSync(stdioStreamsGroups, options); return stdioStreamsGroups;};
const forbiddenIfStreamSync = ({value, optionName}) => { if (isNodeStream(value)) { forbiddenIfSync({type: 'nodeStream', optionName}); }
return {};};
const forbiddenIfSync = ({type, optionName}) => { throw new TypeError(`The \`${optionName}\` option cannot be ${TYPE_TO_MESSAGE[type]} in sync mode.`);};
4 unmodified lines filePath: ({value}) => ({value: bufferToUint8Array(readFileSync(value.file)), type: 'uint8Array'}), webStream: forbiddenIfSync, nodeStream: forbiddenIfSync, iterable: forbiddenIfSync, native: forbiddenIfStreamSync, }, output: { generator: forbiddenIfSync, filePath: ({value}) => ({value: value.file}), webStream: forbiddenIfSync, nodeStream: forbiddenIfSync, iterable: forbiddenIfSync, uint8Array: forbiddenIfSync, native: forbiddenIfStreamSync, },};
const addInputOptionSync = (stdioStreamsGroups, options) => { const inputs = stdioStreamsGroups.flat().filter(({type}) => type === 'string' || type === 'uint8Array'); const inputs = stdioStreamsGroups.flat().filter(({direction, type}) => direction === 'input' && (type === 'string' || type === 'uint8Array')); if (inputs.length === 0) { return; }
29 unmodified linesmodified:test/helpers/stdio.js+1 added-1 removed
12345567898 unmodified linesimport process from 'node:process';
export const identity = value => value;
export const getStdio = (indexOrName, stdioOption, length) => {export const getStdio = (indexOrName, stdioOption, length = 3) => { if (typeof indexOrName === 'string') { return {[indexOrName]: stdioOption}; }
8 unmodified linesmodified:test/stdio/node-stream.js+28 added-18 removed
15 unmodified lines16 stream.end();17 return stream;18 };19 20-const testNodeStreamSync = (t, StreamClass, index, optionName) => {20+const testNoFileStreamSync = async (t, index, StreamClass) => {21 t.throws(() => {22 execaSync('empty.js', getStdio(index, new StreamClass()));23- }, {message: `The \`${optionName}\` option cannot be a Node.js stream in sync mode.`});23+ }, {code: 'ERR_INVALID_ARG_VALUE'});24 };25 26-test('input cannot be a Node.js Readable - sync', testNodeStreamSync, Readable, 'input', 'input');27-test('stdin cannot be a Node.js Readable - sync', testNodeStreamSync, Readable, 0, 'stdin');28-test('stdio[*] cannot be a Node.js Readable - sync', testNodeStreamSync, Readable, 3, 'stdio[3]');29-test('stdout cannot be a Node.js Writable - sync', testNodeStreamSync, Writable, 1, 'stdout');30-test('stderr cannot be a Node.js Writable - sync', testNodeStreamSync, Writable, 2, 'stderr');31-test('stdio[*] cannot be a Node.js Writable - sync', testNodeStreamSync, Writable, 3, 'stdio[3]');26+test('stdin cannot be a Node.js Readable without a file descriptor - sync', testNoFileStreamSync, 0, Readable);27+test('stdout cannot be a Node.js Writable without a file descriptor - sync', testNoFileStreamSync, 1, Writable);28+test('stderr cannot be a Node.js Writable without a file descriptor - sync', testNoFileStreamSync, 2, Writable);29+test('stdio[*] cannot be a Node.js Readable without a file descriptor - sync', testNoFileStreamSync, 3, Readable);30+test('stdio[*] cannot be a Node.js Writable without a file descriptor - sync', testNoFileStreamSync, 3, Writable);31 32 test('input can be a Node.js Readable without a file descriptor', async t => {33 const {stdout} = await execa('stdin.js', {input: createNoFileReadable('foobar')});34 t.is(stdout, 'foobar');35 });36 37+test('input cannot be a Node.js Readable without a file descriptor - sync', t => {38+ t.throws(() => {39+ execaSync('empty.js', {input: createNoFileReadable('foobar')});40+ }, {message: 'The `input` option cannot be a Node.js stream in sync mode.'});41+});42+43 const testNoFileStream = async (t, index, StreamClass) => {44 await t.throwsAsync(execa('empty.js', getStdio(index, new StreamClass())), {code: 'ERR_INVALID_ARG_VALUE'});45 };46 2 unmodified lines49 test('stderr cannot be a Node.js Writable without a file descriptor', testNoFileStream, 2, Writable);50 test('stdio[*] cannot be a Node.js Readable without a file descriptor', testNoFileStream, 3, Readable);51 test('stdio[*] cannot be a Node.js Writable without a file descriptor', testNoFileStream, 3, Writable);52 48-const testFileReadable = async (t, index) => {53+const testFileReadable = async (t, index, execaMethod) => {54 const filePath = tempfile();55 await writeFile(filePath, 'foobar');56 const stream = createReadStream(filePath);57 await once(stream, 'open');58 59 const indexString = index === 'input' ? '0' : `${index}`;55- const {stdout} = await execa('stdin-fd.js', [indexString], getStdio(index, stream));60+ const {stdout} = await execaMethod('stdin-fd.js', [indexString], getStdio(index, stream));61 t.is(stdout, 'foobar');62 63 await rm(filePath);64 };65 61-test('input can be a Node.js Readable with a file descriptor', testFileReadable, 'input');62-test('stdin can be a Node.js Readable with a file descriptor', testFileReadable, 0);63-test('stdio[*] can be a Node.js Readable with a file descriptor', testFileReadable, 3);66+test('input can be a Node.js Readable with a file descriptor', testFileReadable, 'input', execa);67+test('stdin can be a Node.js Readable with a file descriptor', testFileReadable, 0, execa);68+test('stdio[*] can be a Node.js Readable with a file descriptor', testFileReadable, 3, execa);69+test('stdin can be a Node.js Readable with a file descriptor - sync', testFileReadable, 0, execaSync);70+test('stdio[*] can be a Node.js Readable with a file descriptor - sync', testFileReadable, 3, execaSync);71 65-const testFileWritable = async (t, index) => {72+const testFileWritable = async (t, index, execaMethod) => {73 const filePath = tempfile();74 const stream = createWriteStream(filePath);75 await once(stream, 'open');76 70- await execa('noop-fd.js', [`${index}`, 'foobar'], getStdio(index, stream));77+ await execaMethod('noop-fd.js', [`${index}`, 'foobar'], getStdio(index, stream));78 t.is(await readFile(filePath, 'utf8'), 'foobar');79 80 await rm(filePath);81 };82 76-test('stdout can be a Node.js Writable with a file descriptor', testFileWritable, 1);77-test('stderr can be a Node.js Writable with a file descriptor', testFileWritable, 2);78-test('stdio[*] can be a Node.js Writable with a file descriptor', testFileWritable, 3);83+test('stdout can be a Node.js Writable with a file descriptor', testFileWritable, 1, execa);84+test('stderr can be a Node.js Writable with a file descriptor', testFileWritable, 2, execa);85+test('stdio[*] can be a Node.js Writable with a file descriptor', testFileWritable, 3, execa);86+test('stdout can be a Node.js Writable with a file descriptor - sync', testFileWritable, 1, execaSync);87+test('stderr can be a Node.js Writable with a file descriptor - sync', testFileWritable, 2, execaSync);88+test('stdio[*] can be a Node.js Writable with a file descriptor - sync', testFileWritable, 3, execaSync);89 90 const testLazyFileReadable = async (t, index) => {91 const filePath = tempfile();92 await writeFile(filePath, 'foobar');24 unmodified linesmodified:index.d.ts+25 added-15 removed
36 unmodified lines37 }>;38 39 type InputStdioOption<IsSync extends boolean = boolean> =40 | Uint8Array41+ | Readable42 | IfAsync<IsSync,43 | Iterable<string | Uint8Array>44 | AsyncIterable<string | Uint8Array>44- | Readable45 | ReadableStream>;46 47-type OutputStdioOption<IsSync extends boolean = boolean> = IfAsync<IsSync,48-| Writable49-| WritableStream>;47+type OutputStdioOption<IsSync extends boolean = boolean> =48+ | Writable49+ | IfAsync<IsSync, WritableStream>;50 51+type StdinSingleOption<IsSync extends boolean = boolean> =52+ | CommonStdioOption<IsSync>53+ | InputStdioOption<IsSync>;54 export type StdinOption<IsSync extends boolean = boolean> =52- CommonStdioOption<IsSync> | InputStdioOption<IsSync>53- | Array<CommonStdioOption<IsSync> | InputStdioOption<IsSync>>;55+ | StdinSingleOption<IsSync>56+ | Array<StdinSingleOption<IsSync>>;57+type StdoutStderrSingleOption<IsSync extends boolean = boolean> =58+ | CommonStdioOption<IsSync>59+ | OutputStdioOption<IsSync>;60 export type StdoutStderrOption<IsSync extends boolean = boolean> =55- CommonStdioOption<IsSync> | OutputStdioOption<IsSync>56- | Array<CommonStdioOption<IsSync> | OutputStdioOption<IsSync>>;61+ | StdoutStderrSingleOption<IsSync>62+ | Array<StdoutStderrSingleOption<IsSync>>;63+type StdioSingleOption<IsSync extends boolean = boolean> =64+ | CommonStdioOption<IsSync>65+ | InputStdioOption<IsSync>66+ | OutputStdioOption<IsSync>;67 export type StdioOption<IsSync extends boolean = boolean> =58- CommonStdioOption<IsSync> | InputStdioOption | OutputStdioOption<IsSync>59- | Array<CommonStdioOption<IsSync> | InputStdioOption | OutputStdioOption<IsSync>>;68+ | StdioSingleOption<IsSync>69+ | Array<StdioSingleOption<IsSync>>;70 71 type StdioOptionsArray<IsSync extends boolean = boolean> = readonly [72 StdinOption<IsSync>,73 StdoutStderrOption<IsSync>,160 unmodified lines234 Write some input to the child process' `stdin`.235 236 See also the `inputFile` and `stdin` options.237 */228- readonly input?: string | Uint8Array | IfAsync<IsSync, Readable>;238+ readonly input?: string | Uint8Array | Readable;239 240 /**241 Use a file as input to the child process' `stdin`.242 645 unmodified lines888 889 /**890 Same as `execa()` but synchronous.891 882-Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization` and `signal`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be a stream nor an iterable.892+Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization` and `signal`. 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.893 894 @param file - The program/script to execute, as a string or file URL895 @param arguments - Arguments to pass to `file` on execution.896 @returns A `childProcessResult` object90 unmodified lines987 988 /**989 Same as `execaCommand()` but synchronous.990 981-Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization` and `signal`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be a stream nor an iterable.991+Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization` and `signal`. 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.992 993 @param command - The program/script to execute and its arguments.994 @returns A `childProcessResult` object995 @throws A `childProcessResult` error48 unmodified lines1044 1045 /**1046 Same as $\`command\` but synchronous.1047 1038- Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization` and `signal`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be a stream nor an iterable.1048+ Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization` and `signal`. 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.1049 1050 @returns A `childProcessResult` object1051 @throws A `childProcessResult` error1052 43 unmodified lines1096 1097 /**1098 Same as $\`command\` but synchronous.1099 1090- Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization` and `signal`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be a stream nor an iterable.1100+ Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization` and `signal`. 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.1101 1102 @returns A `childProcessResult` object1103 @throws A `childProcessResult` error1104 135 unmodified linesmodified:index.test-d.ts+23 added-23 removed
627 unmodified lines628 execaSync('unicorns', {input: ''});629 execa('unicorns', {input: new Uint8Array()});630 execaSync('unicorns', {input: new Uint8Array()});631 execa('unicorns', {input: process.stdin});632-expectError(execaSync('unicorns', {input: process.stdin}));632+execaSync('unicorns', {input: process.stdin});633 execa('unicorns', {inputFile: ''});634 execaSync('unicorns', {inputFile: ''});635 execa('unicorns', {inputFile: fileUrl});636 execaSync('unicorns', {inputFile: fileUrl});17 unmodified lines654 execaSync('unicorns', {stdin: 'inherit'});655 execa('unicorns', {stdin: ['inherit']});656 execaSync('unicorns', {stdin: ['inherit']});657 execa('unicorns', {stdin: process.stdin});658-expectError(execaSync('unicorns', {stdin: process.stdin}));658+execaSync('unicorns', {stdin: process.stdin});659 execa('unicorns', {stdin: [process.stdin]});660-expectError(execaSync('unicorns', {stdin: [process.stdin]}));660+execaSync('unicorns', {stdin: [process.stdin]});661 execa('unicorns', {stdin: new Readable()});662-expectError(execaSync('unicorns', {stdin: new Readable()}));662+execaSync('unicorns', {stdin: new Readable()});663 execa('unicorns', {stdin: [new Readable()]});664-expectError(execaSync('unicorns', {stdin: [new Readable()]}));664+execaSync('unicorns', {stdin: [new Readable()]});665 expectError(execa('unicorns', {stdin: new Writable()}));666 expectError(execaSync('unicorns', {stdin: new Writable()}));667 expectError(execa('unicorns', {stdin: [new Writable()]}));668 expectError(execaSync('unicorns', {stdin: [new Writable()]}));81 unmodified lines750 execaSync('unicorns', {stdout: 'inherit'});751 execa('unicorns', {stdout: ['inherit']});752 execaSync('unicorns', {stdout: ['inherit']});753 execa('unicorns', {stdout: process.stdout});754-expectError(execaSync('unicorns', {stdout: process.stdout}));754+execaSync('unicorns', {stdout: process.stdout});755 execa('unicorns', {stdout: [process.stdout]});756-expectError(execaSync('unicorns', {stdout: [process.stdout]}));756+execaSync('unicorns', {stdout: [process.stdout]});757 execa('unicorns', {stdout: new Writable()});758-expectError(execaSync('unicorns', {stdout: new Writable()}));758+execaSync('unicorns', {stdout: new Writable()});759 execa('unicorns', {stdout: [new Writable()]});760-expectError(execaSync('unicorns', {stdout: [new Writable()]}));760+execaSync('unicorns', {stdout: [new Writable()]});761 expectError(execa('unicorns', {stdout: new Readable()}));762 expectError(execaSync('unicorns', {stdout: new Readable()}));763 expectError(execa('unicorn', {stdout: [new Readable()]}));764 expectError(execaSync('unicorn', {stdout: [new Readable()]}));63 unmodified lines828 execaSync('unicorns', {stderr: 'inherit'});829 execa('unicorns', {stderr: ['inherit']});830 execaSync('unicorns', {stderr: ['inherit']});831 execa('unicorns', {stderr: process.stderr});832-expectError(execaSync('unicorns', {stderr: process.stderr}));832+execaSync('unicorns', {stderr: process.stderr});833 execa('unicorns', {stderr: [process.stderr]});834-expectError(execaSync('unicorns', {stderr: [process.stderr]}));834+execaSync('unicorns', {stderr: [process.stderr]});835 execa('unicorns', {stderr: new Writable()});836-expectError(execaSync('unicorns', {stderr: new Writable()}));836+execaSync('unicorns', {stderr: new Writable()});837 execa('unicorns', {stderr: [new Writable()]});838-expectError(execaSync('unicorns', {stderr: [new Writable()]}));838+execaSync('unicorns', {stderr: [new Writable()]});839 expectError(execa('unicorns', {stderr: new Readable()}));840 expectError(execaSync('unicorns', {stderr: new Readable()}));841 expectError(execa('unicorns', {stderr: [new Readable()]}));842 expectError(execaSync('unicorns', {stderr: [new Readable()]}));95 unmodified lines938 expectError(execaSync('unicorns', {stdio: asyncStringGenerator()}));939 expectError(execa('unicorns', {stdio: ['pipe', 'pipe']}));940 expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe']}));941 execa('unicorns', {stdio: [new Readable(), 'pipe', 'pipe']});942-expectError(execaSync('unicorns', {stdio: [new Readable(), 'pipe', 'pipe']}));942+execaSync('unicorns', {stdio: [new Readable(), 'pipe', 'pipe']});943 execa('unicorns', {stdio: [[new Readable()], ['pipe'], ['pipe']]});944-expectError(execaSync('unicorns', {stdio: [[new Readable()], ['pipe'], ['pipe']]}));944+execaSync('unicorns', {stdio: [[new Readable()], ['pipe'], ['pipe']]});945 execa('unicorns', {stdio: ['pipe', new Writable(), 'pipe']});946-expectError(execaSync('unicorns', {stdio: ['pipe', new Writable(), 'pipe']}));946+execaSync('unicorns', {stdio: ['pipe', new Writable(), 'pipe']});947 execa('unicorns', {stdio: [['pipe'], [new Writable()], ['pipe']]});948-expectError(execaSync('unicorns', {stdio: [['pipe'], [new Writable()], ['pipe']]}));948+execaSync('unicorns', {stdio: [['pipe'], [new Writable()], ['pipe']]});949 execa('unicorns', {stdio: ['pipe', 'pipe', new Writable()]});950-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', new Writable()]}));950+execaSync('unicorns', {stdio: ['pipe', 'pipe', new Writable()]});951 execa('unicorns', {stdio: [['pipe'], ['pipe'], [new Writable()]]});952-expectError(execaSync('unicorns', {stdio: [['pipe'], ['pipe'], [new Writable()]]}));952+execaSync('unicorns', {stdio: [['pipe'], ['pipe'], [new Writable()]]});953 expectError(execa('unicorns', {stdio: [new Writable(), 'pipe', 'pipe']}));954 expectError(execaSync('unicorns', {stdio: [new Writable(), 'pipe', 'pipe']}));955 expectError(execa('unicorns', {stdio: [[new Writable()], ['pipe'], ['pipe']]}));956 expectError(execaSync('unicorns', {stdio: [[new Writable()], ['pipe'], ['pipe']]}));40 unmodified lines997 1,998 undefined,999 fileUrl,1000 {file: './test'},1001+ new Writable(),1002+ new Readable(),1003 new Uint8Array(),1004 ],1005 });1006 expectError(execaSync('unicorns', {stdio: [stringOrUint8ArrayGenerator]}));1007 expectError(execaSync('unicorns', {stdio: [{transform: stringOrUint8ArrayGenerator}]}));1006-expectError(execaSync('unicorns', {stdio: [new Writable()]}));1007-expectError(execaSync('unicorns', {stdio: [new Readable()]}));1008 expectError(execaSync('unicorns', {stdio: [new WritableStream()]}));1009 expectError(execaSync('unicorns', {stdio: [new ReadableStream()]}));1010 expectError(execaSync('unicorns', {stdio: [emptyStringGenerator()]}));1011 expectError(execaSync('unicorns', {stdio: [asyncStringGenerator()]}));34 unmodified lines1046 [1],1047 [undefined],1048 [fileUrl],1049 [{file: './test'}],1050+ [new Writable()],1051+ [new Readable()],1052 [new Uint8Array()],1053 ],1054 });1055 expectError(execaSync('unicorns', {stdio: [[stringOrUint8ArrayGenerator]]}));1056 expectError(execaSync('unicorns', {stdio: [[{transform: stringOrUint8ArrayGenerator}]]}));1055-expectError(execaSync('unicorns', {stdio: [[new Writable()]]}));1056-expectError(execaSync('unicorns', {stdio: [[new Readable()]]}));1057 expectError(execaSync('unicorns', {stdio: [[new WritableStream()]]}));1058 expectError(execaSync('unicorns', {stdio: [[new ReadableStream()]]}));1059 expectError(execaSync('unicorns', {stdio: [[emptyStringGenerator()]]}));1060 expectError(execaSync('unicorns', {stdio: [[asyncStringGenerator()]]}));141 unmodified linesmodified:readme.md+6 added-6 removed
290 unmodified lines291 ### execaSync(file, arguments?, options?)292 293 Same as [`execa()`](#execacommandcommand-options) but synchronous.294 295-Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`serialization`](#serialization) and [`signal`](#signal). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be a stream nor an iterable.295+Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`serialization`](#serialization) and [`signal`](#signal). 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.296 297 Returns or throws a [`childProcessResult`](#childProcessResult).298 299 ### $.sync\`command\`300 ### $.s\`command\`301 302 Same as [$\`command\`](#command) but synchronous.303 304-Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`serialization`](#serialization) and [`signal`](#signal). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be a stream nor an iterable.304+Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`serialization`](#serialization) and [`signal`](#signal). 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.305 306 Returns or throws a [`childProcessResult`](#childProcessResult).307 308 ### execaCommandSync(command, options?)309 310 Same as [`execaCommand()`](#execacommand-command-options) but synchronous.311 312-Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`serialization`](#serialization) and [`signal`](#signal). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be a stream nor an iterable.312+Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`serialization`](#serialization) and [`signal`](#signal). 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.313 314 Returns or throws a [`childProcessResult`](#childProcessResult).315 316 ### Shell syntax515 unmodified lines832 The [`stdin`](#stdin), [`stdout`](#stdout-1) and [`stderr`](#stderr-1) options can be an array of values.833 The following example redirects `stdout` to both the terminal and an `output.txt` file, while also retrieving its value programmatically.834 835 ```js836-const {stdout} = await execa('npm', ['install'], {stdout: ['inherit', './output.txt', 'pipe']})836+const {stdout} = await execa('npm', ['install'], {stdout: ['inherit', './output.txt', 'pipe']});837 console.log(stdout);838 ```839 840 When combining `inherit` with other values, please note that the child process will not be an interactive TTY, even if the parent process is one.10 unmodified lines851 - a web stream ([`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) or [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream))852 - `[nodeStream, 'pipe']` instead of `nodeStream`853 854 ```diff855-- await execa(..., { stdout: nodeStream })856-+ await execa(..., { stdout: [nodeStream, 'pipe'] })855+- await execa(..., {stdout: nodeStream});856++ await execa(..., {stdout: [nodeStream, 'pipe']});857 ```858 859 ### Retry on error860 86 unmodified lines