Add support for sync iterables with `execaSync()` (#944)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent 5842e34 · Browse files · 9 files·+145 added−71 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
9 files+145 added−71 removed
- tests:+89 added−37 removed
- other:+56 added−34 removed
Provenance
- Commit
f744f7d- Tree
be35577- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
5842e34
9 files changed+145 added−71 removed
modified:lib/stdio/async.js+2 added
32 unmodified lines3334353637383940414243444546474849505163 unmodified lines32 unmodified lines fileUrl: ({value}) => ({stream: createReadStream(value)}), filePath: ({value: {file}}) => ({stream: createReadStream(file)}), webStream: ({value}) => ({stream: Readable.fromWeb(value)}), iterable: ({value}) => ({stream: Readable.from(value)}), asyncIterable: ({value}) => ({stream: Readable.from(value)}), string: ({value}) => ({stream: Readable.from(value)}), uint8Array: ({value}) => ({stream: Readable.from(Buffer.from(value))}), }, output: { ...addProperties, fileUrl: ({value}) => ({stream: createWriteStream(value)}), filePath: ({value: {file}}) => ({stream: createWriteStream(file)}), webStream: ({value}) => ({stream: Writable.fromWeb(value)}), iterable: forbiddenIfAsync, asyncIterable: forbiddenIfAsync, string: forbiddenIfAsync, uint8Array: forbiddenIfAsync, },};63 unmodified linesmodified:lib/stdio/direction.js+1 added
32 unmodified lines33343536373839404139 unmodified lines32 unmodified lines generator: anyDirection, fileUrl: anyDirection, filePath: anyDirection, iterable: alwaysInput, asyncIterable: alwaysInput, uint8Array: alwaysInput, webStream: value => isWritableStream(value) ? 'output' : 'input', nodeStream(value) { const standardStreamDirection = getStandardStreamDirection(value);39 unmodified linesmodified:lib/stdio/sync.js+18 added-7 removed
1 import {readFileSync, writeFileSync} from 'node:fs';2 import {isStream as isNodeStream} from 'is-stream';3-import {bufferToUint8Array, uint8ArrayToString} from '../utils.js';3+import {bufferToUint8Array, uint8ArrayToString, isUint8Array} 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 mode25 unmodified lines33 webStream: forbiddenIfSync,34 nodeStream: forbiddenIfSync,35 webTransform: forbiddenIfSync,36 duplex: forbiddenIfSync,37- iterable: forbiddenIfSync,37+ asyncIterable: forbiddenIfSync,38 native: forbiddenNativeIfSync,39 };40 41 const addPropertiesSync = {42 input: {43 ...addProperties,44- fileUrl: ({value}) => ({contents: bufferToUint8Array(readFileSync(value))}),45- filePath: ({value: {file}}) => ({contents: bufferToUint8Array(readFileSync(file))}),46- string: ({value}) => ({contents: value}),47- uint8Array: ({value}) => ({contents: value}),44+ fileUrl: ({value}) => ({contents: [bufferToUint8Array(readFileSync(value))]}),45+ filePath: ({value: {file}}) => ({contents: [bufferToUint8Array(readFileSync(file))]}),46+ iterable: ({value}) => ({contents: [...value]}),47+ string: ({value}) => ({contents: [value]}),48+ uint8Array: ({value}) => ({contents: [value]}),49 },50 output: {51 ...addProperties,52 fileUrl: ({value}) => ({path: value}),53 filePath: ({value: {file}}) => ({path: file}),54+ iterable: forbiddenIfSync,55 string: forbiddenIfSync,56 uint8Array: forbiddenIfSync,57 },58 };66 unmodified lines125 throw new TypeError(`Only the \`stdin\` option, not \`${optionName}\`, can be ${TYPE_TO_MESSAGE[type]} with synchronous methods.`);126 }127 128 const allContents = allStdioItems.map(({contents}) => contents);127- options.input = allContents.length === 1129+ options.input = serializeAllContents(allContents.flat());130+};131+132+const serializeAllContents = allContents => {133+ const invalidContents = allContents.find(contents => typeof contents !== 'string' && !isUint8Array(contents));134+ if (invalidContents !== undefined) {135+ throw new TypeError(`The \`stdin\` option is invalid: only strings or Uint8Arrays can be yielded from iterables when using the synchronous methods: ${invalidContents}.`);136+ }137+138+ return allContents.length === 1139 ? allContents[0]140 : allContents.map(contents => serializeContents(contents)).join('');141 };142 24 unmodified linesmodified:lib/stdio/type.js+8 added-3 removed
26 unmodified lines27 if (isUint8Array(value)) {28 return 'uint8Array';29 }30 31+ if (isAsyncIterableObject(value)) {32+ return 'asyncIterable';33+ }34+35 if (isIterableObject(value)) {36 return 'iterable';37 }38 94 unmodified lines133 export const isWritableStream = value => Object.prototype.toString.call(value) === '[object WritableStream]';134 const isWebStream = value => isReadableStream(value) || isWritableStream(value);135 const isTransformStream = value => isReadableStream(value?.readable) && isWritableStream(value?.writable);136 133-const isIterableObject = value => typeof value === 'object'134- && value !== null135- && (typeof value[Symbol.asyncIterator] === 'function' || typeof value[Symbol.iterator] === 'function');137+const isAsyncIterableObject = value => isObject(value) && typeof value[Symbol.asyncIterator] === 'function';138+const isIterableObject = value => isObject(value) && typeof value[Symbol.iterator] === 'function';139+const isObject = value => typeof value === 'object' && value !== null;140 141 // Convert types to human-friendly strings for error messages142 export const TYPE_TO_MESSAGE = {143 generator: 'a generator',4 unmodified lines148 webTransform: 'a web TransformStream',149 duplex: 'a Duplex stream',150 native: 'any value',151 iterable: 'an iterable',152+ asyncIterable: 'an async iterable',153 string: 'a string',154 uint8Array: 'a Uint8Array',155 };modified:test/stdio/iterable.js+88 added-37 removed
2 unmodified lines3 import test from 'ava';4 import {execa, execaSync} from '../../index.js';5 import {setFixtureDir} from '../helpers/fixtures-dir.js';6 import {getStdio} from '../helpers/stdio.js';7-import {foobarObject, foobarObjectString} from '../helpers/input.js';7+import {foobarObject, foobarObjectString, foobarArray} from '../helpers/input.js';8 import {serializeGenerator, infiniteGenerator, throwingGenerator} from '../helpers/generator.js';9 10-const stringArray = ['foo', 'bar'];11-10 const stringGenerator = function * () {13- yield * stringArray;11+ yield * foobarArray;12 };13 14 const textEncoder = new TextEncoder();15 const binaryFoo = textEncoder.encode('foo');3 unmodified lines19 const binaryGenerator = function * () {20 yield * binaryArray;21 };22 23+const mixedArray = [foobarArray[0], binaryArray[1]];24+25+const mixedGenerator = function * () {26+ yield * mixedArray;27+};28+29 const asyncGenerator = async function * () {30 await setImmediate();27- yield * stringArray;31+ yield * foobarArray;32 };33 34 setFixtureDir();35 32-const testIterable = async (t, stdioOption, fdNumber) => {33- const {stdout} = await execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, stdioOption));36+const testIterable = async (t, stdioOption, fdNumber, execaMethod) => {37+ const {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, stdioOption));38 t.is(stdout, 'foobar');39 };40 37-test.serial('stdin option can be an array of strings', testIterable, [stringArray], 0);38-test.serial('stdio[*] option can be an array of strings', testIterable, [stringArray], 3);39-test.serial('stdin option can be an array of Uint8Arrays', testIterable, [binaryArray], 0);40-test.serial('stdio[*] option can be an array of Uint8Arrays', testIterable, [binaryArray], 3);41-test.serial('stdin option can be an iterable of strings', testIterable, stringGenerator(), 0);42-test.serial('stdio[*] option can be an iterable of strings', testIterable, stringGenerator(), 3);43-test.serial('stdin option can be an iterable of Uint8Arrays', testIterable, binaryGenerator(), 0);44-test.serial('stdio[*] option can be an iterable of Uint8Arrays', testIterable, binaryGenerator(), 3);45-test.serial('stdin option can be an async iterable', testIterable, asyncGenerator(), 0);46-test.serial('stdio[*] option can be an async iterable', testIterable, asyncGenerator(), 3);41+test.serial('stdin option can be an array of strings', testIterable, [foobarArray], 0, execa);42+test.serial('stdin option can be an array of strings - sync', testIterable, [foobarArray], 0, execaSync);43+test.serial('stdio[*] option can be an array of strings', testIterable, [foobarArray], 3, execa);44+test.serial('stdin option can be an array of Uint8Arrays', testIterable, [binaryArray], 0, execa);45+test.serial('stdin option can be an array of Uint8Arrays - sync', testIterable, [binaryArray], 0, execaSync);46+test.serial('stdio[*] option can be an array of Uint8Arrays', testIterable, [binaryArray], 3, execa);47+test.serial('stdin option can be an iterable of strings', testIterable, stringGenerator(), 0, execa);48+test.serial('stdin option can be an iterable of strings - sync', testIterable, stringGenerator(), 0, execaSync);49+test.serial('stdio[*] option can be an iterable of strings', testIterable, stringGenerator(), 3, execa);50+test.serial('stdin option can be an iterable of Uint8Arrays', testIterable, binaryGenerator(), 0, execa);51+test.serial('stdin option can be an iterable of Uint8Arrays - sync', testIterable, binaryGenerator(), 0, execaSync);52+test.serial('stdio[*] option can be an iterable of Uint8Arrays', testIterable, binaryGenerator(), 3, execa);53+test.serial('stdin option can be an iterable of strings + Uint8Arrays', testIterable, mixedGenerator(), 0, execa);54+test.serial('stdin option can be an iterable of strings + Uint8Arrays - sync', testIterable, mixedGenerator(), 0, execaSync);55+test.serial('stdio[*] option can be an iterable of strings + Uint8Arrays', testIterable, mixedGenerator(), 3, execa);56+test.serial('stdin option can be an async iterable', testIterable, asyncGenerator(), 0, execa);57+test.serial('stdio[*] option can be an async iterable', testIterable, asyncGenerator(), 3, execa);58 59 const foobarObjectGenerator = function * () {60 yield foobarObject;61 };62 52-const foobarAsyncObjectGenerator = function * () {63+const foobarAsyncObjectGenerator = async function * () {64 yield foobarObject;65 };66 67 const testObjectIterable = async (t, stdioOption, fdNumber) => {13 unmodified lines81 execaSync('empty.js', getStdio(fdNumber, stdioOption));82 }, {message: /an iterable with synchronous methods/});83 };84 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);76-test('stdin option cannot be a sync iterable - sync', testIterableSync, stringGenerator(), 0);77-test('stdio[*] option cannot be a sync iterable - sync', testIterableSync, stringGenerator(), 3);78-test('stdin option cannot be an async iterable - sync', testIterableSync, asyncGenerator(), 0);79-test('stdio[*] option cannot be an async iterable - sync', testIterableSync, asyncGenerator(), 3);85+test('stdio[*] option cannot be an array of strings - sync', testIterableSync, [foobarArray], 3);86+test('stdio[*] option cannot be an array of Uint8Arrays - sync', testIterableSync, [binaryArray], 3);87+test('stdio[*] option cannot be an array of objects - sync', testIterableSync, [[foobarObject]], 3);88+test('stdio[*] option cannot be an iterable of strings - sync', testIterableSync, stringGenerator(), 3);89+test('stdio[*] option cannot be an iterable of Uint8Arrays - sync', testIterableSync, binaryGenerator(), 3);90+test('stdio[*] option cannot be an iterable of objects - sync', testIterableSync, foobarObjectGenerator(), 3);91+test('stdio[*] option cannot be multiple iterables - sync', testIterableSync, [stringGenerator(), stringGenerator()], 3);92 93+const testIterableObjectSync = (t, stdioOption, fdNumber) => {94+ t.throws(() => {95+ execaSync('empty.js', getStdio(fdNumber, stdioOption));96+ }, {message: /only strings or Uint8Arrays/});97+};98+99+test('stdin option cannot be an array of objects - sync', testIterableObjectSync, [[foobarObject]], 0);100+test('stdin option cannot be an iterable of objects - sync', testIterableObjectSync, foobarObjectGenerator(), 0);101+102+const testAsyncIterableSync = (t, stdioOption, fdNumber) => {103+ t.throws(() => {104+ execaSync('empty.js', getStdio(fdNumber, stdioOption));105+ }, {message: /an async iterable with synchronous method/});106+};107+108+test('stdin option cannot be an async iterable - sync', testAsyncIterableSync, asyncGenerator(), 0);109+test('stdio[*] option cannot be an async iterable - sync', testAsyncIterableSync, asyncGenerator(), 3);110+test('stdin option cannot be an async iterable of objects - sync', testAsyncIterableSync, foobarAsyncObjectGenerator(), 0);111+test('stdio[*] option cannot be an async iterable of objects - sync', testAsyncIterableSync, foobarAsyncObjectGenerator(), 3);112+81-const testIterableError = async (t, fdNumber) => {82- const {originalMessage} = await t.throwsAsync(execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, throwingGenerator().transform())));113+const testIterableError = async (t, fdNumber, execaMethod) => {114+ const {originalMessage} = await t.throwsAsync(execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, throwingGenerator().transform())));115 t.is(originalMessage, 'Generator error');116 };117 86-test('stdin option handles errors in iterables', testIterableError, 0);87-test('stdio[*] option handles errors in iterables', testIterableError, 3);118+test('stdin option handles errors in iterables', testIterableError, 0, execa);119+test('stdio[*] option handles errors in iterables', testIterableError, 3, execa);120 121+const testIterableErrorSync = (t, fdNumber, execaMethod) => {122+ t.throws(() => {123+ execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, throwingGenerator().transform()));124+ }, {message: 'Generator error'});125+};126+127+test('stdin option handles errors in iterables - sync', testIterableErrorSync, 0, execaSync);128+test('stdio[*] option handles errors in iterables - sync', testIterableErrorSync, 3, execaSync);129+130 const testNoIterableOutput = (t, stdioOption, fdNumber, execaMethod) => {131 t.throws(() => {132 execaMethod('empty.js', getStdio(fdNumber, stdioOption));133 }, {message: /cannot be an iterable/});134 };135 95-test('stdout option cannot be an array of strings', testNoIterableOutput, [stringArray], 1, execa);96-test('stderr option cannot be an array of strings', testNoIterableOutput, [stringArray], 2, execa);97-test('stdout option cannot be an array of strings - sync', testNoIterableOutput, [stringArray], 1, execaSync);98-test('stderr option cannot be an array of strings - sync', testNoIterableOutput, [stringArray], 2, execaSync);136+test('stdout option cannot be an array of strings', testNoIterableOutput, [foobarArray], 1, execa);137+test('stderr option cannot be an array of strings', testNoIterableOutput, [foobarArray], 2, execa);138+test('stdout option cannot be an array of strings - sync', testNoIterableOutput, [foobarArray], 1, execaSync);139+test('stderr option cannot be an array of strings - sync', testNoIterableOutput, [foobarArray], 2, execaSync);140 test('stdout option cannot be an iterable', testNoIterableOutput, stringGenerator(), 1, execa);141 test('stderr option cannot be an iterable', testNoIterableOutput, stringGenerator(), 2, execa);142 test('stdout option cannot be an iterable - sync', testNoIterableOutput, stringGenerator(), 1, execaSync);143 test('stderr option cannot be an iterable - sync', testNoIterableOutput, stringGenerator(), 2, execaSync);7 unmodified lines151 t.true(stdout.startsWith('foo'));152 t.deepEqual(await iterable.next(), {value: undefined, done: true});153 });154 114-const testMultipleIterable = async (t, fdNumber) => {115- const {stdout} = await execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stringGenerator(), asyncGenerator()]));116- t.is(stdout, 'foobarfoobar');155+const testMultipleIterable = async (t, stdioOption, fdNumber, execaMethod) => {156+ const {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, stdioOption));157+ const expectedOutputs = [158+ `${foobarArray[0]}${foobarArray[1]}${foobarArray[0]}${foobarArray[1]}`,159+ `${foobarArray[0]}${foobarArray[0]}${foobarArray[1]}${foobarArray[1]}`,160+ ];161+ t.true(expectedOutputs.includes(stdout));162 };163 119-test('stdin option can be multiple iterables', testMultipleIterable, 0);120-test('stdio[*] option can be multiple iterables', testMultipleIterable, 3);164+test('stdin option can be multiple iterables', testMultipleIterable, [stringGenerator(), stringGenerator()], 0, execa);165+test('stdio[*] option can be multiple iterables', testMultipleIterable, [stringGenerator(), stringGenerator()], 3, execa);166+test('stdin option can be multiple iterables - sync', testMultipleIterable, [stringGenerator(), stringGenerator()], 0, execaSync);167+test('stdin option can be multiple mixed iterables', testMultipleIterable, [stringGenerator(), binaryGenerator()], 0, execa);168+test('stdio[*] option can be multiple mixed iterables', testMultipleIterable, [stringGenerator(), binaryGenerator()], 3, execa);169+test('stdin option can be multiple mixed iterables - sync', testMultipleIterable, [stringGenerator(), binaryGenerator()], 0, execaSync);170+test('stdin option can be sync/async mixed iterables', testMultipleIterable, [stringGenerator(), asyncGenerator()], 0, execa);171+test('stdio[*] option can be sync/async mixed iterables', testMultipleIterable, [stringGenerator(), asyncGenerator()], 3, execa);172 173 test('stdin option iterable is canceled on subprocess error', async t => {174 const iterable = infiniteGenerator().transform();175 await t.throwsAsync(execa('stdin.js', {stdin: iterable, timeout: 1}), {message: /timed out/});3 unmodified linesmodified:test/stdio/sync.js+1 added
53 unmodified lines54 t.true(message.includes(expectedMessage));55 };56 57 test('Cannot use Uint8Array with stdio[*], sync', testFd3InputSync, new Uint8Array(), getFd3InputMessage('a Uint8Array'));58+test('Cannot use iterable with stdio[*], sync', testFd3InputSync, [[]], getFd3InputMessage('an iterable'));modified:index.d.ts+8 added-5 removed
67 unmodified lines68 | WebTransform69 | TransformStream>;70 71 // Synchronous iterables excluding strings, Uint8Arrays and Arrays72-type IterableObject<IsArray extends boolean = boolean> = Iterable<unknown>72+type IterableObject<73+ IsSync extends boolean = boolean,74+ IsArray extends boolean = boolean,75+> = Iterable<Unless<IsSync, unknown, string | Uint8Array>>76 & object77 & {readonly BYTES_PER_ELEMENT?: never}78 & AndUnless<IsArray, {readonly lastIndexOf?: never}>;79 1 unmodified line81 IsSync extends boolean = boolean,82 IsExtra extends boolean = boolean,83 IsArray extends boolean = boolean,84 > =82- | Unless<And<IsSync, IsExtra>, Uint8Array>85+ | Unless<And<IsSync, IsExtra>, Uint8Array | IterableObject<IsSync, IsArray>>86 | Unless<And<IsSync, IsArray>, Readable>84- | Unless<IsSync, IterableObject<IsArray> | AsyncIterable<unknown> | ReadableStream>;87+ | Unless<IsSync, AsyncIterable<unknown> | ReadableStream>;88 89 type OutputStdioOption<90 IsSync extends boolean = boolean,91 IsArray extends boolean = boolean,1309 unmodified lines1401 Same as `execa()` but synchronous.1402 1403 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.1404 1402-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.1405+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 async iterable, an iterable of objects, a transform, a `Duplex`, or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1406 1407 @param file - The program/script to execute, as a string or file URL1408 @param arguments - Arguments to pass to `file` on execution.1409 @returns A `subprocessResult` object105 unmodified lines1515 Same as `execaCommand()` but synchronous.1516 1517 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.1518 1516-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.1519+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 async iterable, an iterable of objects, a transform, a `Duplex`, or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1520 1521 @param command - The program/script to execute and its arguments.1522 @returns A `subprocessResult` object1523 @throws A `subprocessResult` error128 unmodified linesmodified:index.test-d.ts+18 added-18 removed
2010 unmodified lines2011 expectNotAssignable<StdioOptionSync>(invalidFileObject);2012 expectNotAssignable<StdioOption>([invalidFileObject]);2013 expectNotAssignable<StdioOptionSync>([invalidFileObject]);2014 execa('unicorns', {stdin: [stringArray]});2015-expectError(execaSync('unicorns', {stdin: [stringArray]}));2015+execaSync('unicorns', {stdin: [stringArray]});2016 expectError(execa('unicorns', {stdout: [stringArray]}));2017 expectError(execaSync('unicorns', {stdout: [stringArray]}));2018 expectError(execa('unicorns', {stderr: [stringArray]}));2019 expectError(execaSync('unicorns', {stderr: [stringArray]}));1 unmodified line2021 expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [stringArray]]}));2022 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [[stringArray]]]});2023 expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [[stringArray]]]}));2024 expectAssignable<StdinOption>([stringArray]);2025-expectNotAssignable<StdinOptionSync>([stringArray]);2025+expectAssignable<StdinOptionSync>([stringArray]);2026 expectNotAssignable<StdoutStderrOption>([stringArray]);2027 expectNotAssignable<StdoutStderrOptionSync>([stringArray]);2028 expectAssignable<StdioOption>([stringArray]);2029-expectNotAssignable<StdioOptionSync>([stringArray]);2029+expectAssignable<StdioOptionSync>([stringArray]);2030 execa('unicorns', {stdin: [binaryArray]});2031-expectError(execaSync('unicorns', {stdin: [binaryArray]}));2031+execaSync('unicorns', {stdin: [binaryArray]});2032 expectError(execa('unicorns', {stdout: [binaryArray]}));2033 expectError(execaSync('unicorns', {stdout: [binaryArray]}));2034 expectError(execa('unicorns', {stderr: [binaryArray]}));2035 expectError(execaSync('unicorns', {stderr: [binaryArray]}));1 unmodified line2037 expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [binaryArray]]}));2038 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [[binaryArray]]]});2039 expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [[binaryArray]]]}));2040 expectAssignable<StdinOption>([binaryArray]);2041-expectNotAssignable<StdinOptionSync>([binaryArray]);2041+expectAssignable<StdinOptionSync>([binaryArray]);2042 expectNotAssignable<StdoutStderrOption>([binaryArray]);2043 expectNotAssignable<StdoutStderrOptionSync>([binaryArray]);2044 expectAssignable<StdioOption>([binaryArray]);2045-expectNotAssignable<StdioOptionSync>([binaryArray]);2045+expectAssignable<StdioOptionSync>([binaryArray]);2046 execa('unicorns', {stdin: [objectArray]});2047 expectError(execaSync('unicorns', {stdin: [objectArray]}));2048 expectError(execa('unicorns', {stdout: [objectArray]}));2049 expectError(execaSync('unicorns', {stdout: [objectArray]}));9 unmodified lines2059 expectNotAssignable<StdoutStderrOptionSync>([objectArray]);2060 expectAssignable<StdioOption>([objectArray]);2061 expectNotAssignable<StdioOptionSync>([objectArray]);2062 execa('unicorns', {stdin: stringIterable});2063-expectError(execaSync('unicorns', {stdin: stringIterable}));2063+execaSync('unicorns', {stdin: stringIterable});2064 execa('unicorns', {stdin: [stringIterable]});2065-expectError(execaSync('unicorns', {stdin: [stringIterable]}));2065+execaSync('unicorns', {stdin: [stringIterable]});2066 expectError(execa('unicorns', {stdout: stringIterable}));2067 expectError(execaSync('unicorns', {stdout: stringIterable}));2068 expectError(execa('unicorns', {stdout: [stringIterable]}));2069 expectError(execaSync('unicorns', {stdout: [stringIterable]}));7 unmodified lines2077 expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', stringIterable]}));2078 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [stringIterable]]});2079 expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [stringIterable]]}));2080 expectAssignable<StdinOption>(stringIterable);2081-expectNotAssignable<StdinOptionSync>(stringIterable);2081+expectAssignable<StdinOptionSync>(stringIterable);2082 expectAssignable<StdinOption>([stringIterable]);2083-expectNotAssignable<StdinOptionSync>([stringIterable]);2083+expectAssignable<StdinOptionSync>([stringIterable]);2084 expectNotAssignable<StdoutStderrOption>(stringIterable);2085 expectNotAssignable<StdoutStderrOptionSync>(stringIterable);2086 expectNotAssignable<StdoutStderrOption>([stringIterable]);2087 expectNotAssignable<StdoutStderrOptionSync>([stringIterable]);2088 expectAssignable<StdioOption>(stringIterable);2089-expectNotAssignable<StdioOptionSync>(stringIterable);2089+expectAssignable<StdioOptionSync>(stringIterable);2090 expectAssignable<StdioOption>([stringIterable]);2091-expectNotAssignable<StdioOptionSync>([stringIterable]);2091+expectAssignable<StdioOptionSync>([stringIterable]);2092 execa('unicorns', {stdin: binaryIterable});2093-expectError(execaSync('unicorns', {stdin: binaryIterable}));2093+execaSync('unicorns', {stdin: binaryIterable});2094 execa('unicorns', {stdin: [binaryIterable]});2095-expectError(execaSync('unicorns', {stdin: [binaryIterable]}));2095+execaSync('unicorns', {stdin: [binaryIterable]});2096 expectError(execa('unicorns', {stdout: binaryIterable}));2097 expectError(execaSync('unicorns', {stdout: binaryIterable}));2098 expectError(execa('unicorns', {stdout: [binaryIterable]}));2099 expectError(execaSync('unicorns', {stdout: [binaryIterable]}));7 unmodified lines2107 expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', binaryIterable]}));2108 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [binaryIterable]]});2109 expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [binaryIterable]]}));2110 expectAssignable<StdinOption>(binaryIterable);2111-expectNotAssignable<StdinOptionSync>(binaryIterable);2111+expectAssignable<StdinOptionSync>(binaryIterable);2112 expectAssignable<StdinOption>([binaryIterable]);2113-expectNotAssignable<StdinOptionSync>([binaryIterable]);2113+expectAssignable<StdinOptionSync>([binaryIterable]);2114 expectNotAssignable<StdoutStderrOption>(binaryIterable);2115 expectNotAssignable<StdoutStderrOptionSync>(binaryIterable);2116 expectNotAssignable<StdoutStderrOption>([binaryIterable]);2117 expectNotAssignable<StdoutStderrOptionSync>([binaryIterable]);2118 expectAssignable<StdioOption>(binaryIterable);2119-expectNotAssignable<StdioOptionSync>(binaryIterable);2119+expectAssignable<StdioOptionSync>(binaryIterable);2120 expectAssignable<StdioOption>([binaryIterable]);2121-expectNotAssignable<StdioOptionSync>([binaryIterable]);2121+expectAssignable<StdioOptionSync>([binaryIterable]);2122 execa('unicorns', {stdin: objectIterable});2123 expectError(execaSync('unicorns', {stdin: objectIterable}));2124 execa('unicorns', {stdin: [objectIterable]});2125 expectError(execaSync('unicorns', {stdin: [objectIterable]}));1546 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) 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.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 async iterable, an iterable of objects, 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