Skip to content
Myr

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

9 files+145 added−71 removed

modified:lib/stdio/async.js+2 added
modified:lib/stdio/direction.js+1 added
modified:lib/stdio/sync.js+18 added-7 removed
1import {readFileSync, writeFileSync} from 'node:fs';2import {isStream as isNodeStream} from 'is-stream';3import {bufferToUint8Array, uint8ArrayToString} from '../utils.js';3import {bufferToUint8Array, uint8ArrayToString, isUint8Array} 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 mode
25 unmodified lines
33 webStream: forbiddenIfSync,34 nodeStream: forbiddenIfSync,35 webTransform: forbiddenIfSync,36 duplex: forbiddenIfSync,37 iterable: forbiddenIfSync,37 asyncIterable: forbiddenIfSync,38 native: forbiddenNativeIfSync,39};4041const 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 lines
125 throw new TypeError(`Only the \`stdin\` option, not \`${optionName}\`, can be ${TYPE_TO_MESSAGE[type]} with synchronous methods.`);126 }127128 const allContents = allStdioItems.map(({contents}) => contents);127 options.input = allContents.length === 1129 options.input = serializeAllContents(allContents.flat());130};131132const 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 }137138 return allContents.length === 1139 ? allContents[0]140 : allContents.map(contents => serializeContents(contents)).join('');141};142
24 unmodified lines
modified:lib/stdio/type.js+8 added-3 removed
26 unmodified lines
27 if (isUint8Array(value)) {28 return 'uint8Array';29 }3031 if (isAsyncIterableObject(value)) {32 return 'asyncIterable';33 }3435 if (isIterableObject(value)) {36 return 'iterable';37 }38
94 unmodified lines
133export const isWritableStream = value => Object.prototype.toString.call(value) === '[object WritableStream]';134const isWebStream = value => isReadableStream(value) || isWritableStream(value);135const isTransformStream = value => isReadableStream(value?.readable) && isWritableStream(value?.writable);136133const isIterableObject = value => typeof value === 'object'134 && value !== null135 && (typeof value[Symbol.asyncIterator] === 'function' || typeof value[Symbol.iterator] === 'function');137const isAsyncIterableObject = value => isObject(value) && typeof value[Symbol.asyncIterator] === 'function';138const isIterableObject = value => isObject(value) && typeof value[Symbol.iterator] === 'function';139const isObject = value => typeof value === 'object' && value !== null;140141// Convert types to human-friendly strings for error messages142export const TYPE_TO_MESSAGE = {143 generator: 'a generator',
4 unmodified lines
148 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 lines
3import test from 'ava';4import {execa, execaSync} from '../../index.js';5import {setFixtureDir} from '../helpers/fixtures-dir.js';6import {getStdio} from '../helpers/stdio.js';7import {foobarObject, foobarObjectString} from '../helpers/input.js';7import {foobarObject, foobarObjectString, foobarArray} from '../helpers/input.js';8import {serializeGenerator, infiniteGenerator, throwingGenerator} from '../helpers/generator.js';910const stringArray = ['foo', 'bar'];1110const stringGenerator = function * () {13 yield * stringArray;11 yield * foobarArray;12};1314const textEncoder = new TextEncoder();15const binaryFoo = textEncoder.encode('foo');
3 unmodified lines
19const binaryGenerator = function * () {20 yield * binaryArray;21};2223const mixedArray = [foobarArray[0], binaryArray[1]];2425const mixedGenerator = function * () {26 yield * mixedArray;27};2829const asyncGenerator = async function * () {30 await setImmediate();27 yield * stringArray;31 yield * foobarArray;32};3334setFixtureDir();3532const testIterable = async (t, stdioOption, fdNumber) => {33 const {stdout} = await execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, stdioOption));36const testIterable = async (t, stdioOption, fdNumber, execaMethod) => {37 const {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, stdioOption));38 t.is(stdout, 'foobar');39};4037test.serial('stdin option can be an array of strings', testIterable, [stringArray], 0);38test.serial('stdio[*] option can be an array of strings', testIterable, [stringArray], 3);39test.serial('stdin option can be an array of Uint8Arrays', testIterable, [binaryArray], 0);40test.serial('stdio[*] option can be an array of Uint8Arrays', testIterable, [binaryArray], 3);41test.serial('stdin option can be an iterable of strings', testIterable, stringGenerator(), 0);42test.serial('stdio[*] option can be an iterable of strings', testIterable, stringGenerator(), 3);43test.serial('stdin option can be an iterable of Uint8Arrays', testIterable, binaryGenerator(), 0);44test.serial('stdio[*] option can be an iterable of Uint8Arrays', testIterable, binaryGenerator(), 3);45test.serial('stdin option can be an async iterable', testIterable, asyncGenerator(), 0);46test.serial('stdio[*] option can be an async iterable', testIterable, asyncGenerator(), 3);41test.serial('stdin option can be an array of strings', testIterable, [foobarArray], 0, execa);42test.serial('stdin option can be an array of strings - sync', testIterable, [foobarArray], 0, execaSync);43test.serial('stdio[*] option can be an array of strings', testIterable, [foobarArray], 3, execa);44test.serial('stdin option can be an array of Uint8Arrays', testIterable, [binaryArray], 0, execa);45test.serial('stdin option can be an array of Uint8Arrays - sync', testIterable, [binaryArray], 0, execaSync);46test.serial('stdio[*] option can be an array of Uint8Arrays', testIterable, [binaryArray], 3, execa);47test.serial('stdin option can be an iterable of strings', testIterable, stringGenerator(), 0, execa);48test.serial('stdin option can be an iterable of strings - sync', testIterable, stringGenerator(), 0, execaSync);49test.serial('stdio[*] option can be an iterable of strings', testIterable, stringGenerator(), 3, execa);50test.serial('stdin option can be an iterable of Uint8Arrays', testIterable, binaryGenerator(), 0, execa);51test.serial('stdin option can be an iterable of Uint8Arrays - sync', testIterable, binaryGenerator(), 0, execaSync);52test.serial('stdio[*] option can be an iterable of Uint8Arrays', testIterable, binaryGenerator(), 3, execa);53test.serial('stdin option can be an iterable of strings + Uint8Arrays', testIterable, mixedGenerator(), 0, execa);54test.serial('stdin option can be an iterable of strings + Uint8Arrays - sync', testIterable, mixedGenerator(), 0, execaSync);55test.serial('stdio[*] option can be an iterable of strings + Uint8Arrays', testIterable, mixedGenerator(), 3, execa);56test.serial('stdin option can be an async iterable', testIterable, asyncGenerator(), 0, execa);57test.serial('stdio[*] option can be an async iterable', testIterable, asyncGenerator(), 3, execa);5859const foobarObjectGenerator = function * () {60 yield foobarObject;61};6252const foobarAsyncObjectGenerator = function * () {63const foobarAsyncObjectGenerator = async function * () {64 yield foobarObject;65};6667const testObjectIterable = async (t, stdioOption, fdNumber) => {
13 unmodified lines
81 execaSync('empty.js', getStdio(fdNumber, stdioOption));82 }, {message: /an iterable with synchronous methods/});83};8474test('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);76test('stdin option cannot be a sync iterable - sync', testIterableSync, stringGenerator(), 0);77test('stdio[*] option cannot be a sync iterable - sync', testIterableSync, stringGenerator(), 3);78test('stdin option cannot be an async iterable - sync', testIterableSync, asyncGenerator(), 0);79test('stdio[*] option cannot be an async iterable - sync', testIterableSync, asyncGenerator(), 3);85test('stdio[*] option cannot be an array of strings - sync', testIterableSync, [foobarArray], 3);86test('stdio[*] option cannot be an array of Uint8Arrays - sync', testIterableSync, [binaryArray], 3);87test('stdio[*] option cannot be an array of objects - sync', testIterableSync, [[foobarObject]], 3);88test('stdio[*] option cannot be an iterable of strings - sync', testIterableSync, stringGenerator(), 3);89test('stdio[*] option cannot be an iterable of Uint8Arrays - sync', testIterableSync, binaryGenerator(), 3);90test('stdio[*] option cannot be an iterable of objects - sync', testIterableSync, foobarObjectGenerator(), 3);91test('stdio[*] option cannot be multiple iterables - sync', testIterableSync, [stringGenerator(), stringGenerator()], 3);9293const testIterableObjectSync = (t, stdioOption, fdNumber) => {94 t.throws(() => {95 execaSync('empty.js', getStdio(fdNumber, stdioOption));96 }, {message: /only strings or Uint8Arrays/});97};9899test('stdin option cannot be an array of objects - sync', testIterableObjectSync, [[foobarObject]], 0);100test('stdin option cannot be an iterable of objects - sync', testIterableObjectSync, foobarObjectGenerator(), 0);101102const testAsyncIterableSync = (t, stdioOption, fdNumber) => {103 t.throws(() => {104 execaSync('empty.js', getStdio(fdNumber, stdioOption));105 }, {message: /an async iterable with synchronous method/});106};107108test('stdin option cannot be an async iterable - sync', testAsyncIterableSync, asyncGenerator(), 0);109test('stdio[*] option cannot be an async iterable - sync', testAsyncIterableSync, asyncGenerator(), 3);110test('stdin option cannot be an async iterable of objects - sync', testAsyncIterableSync, foobarAsyncObjectGenerator(), 0);111test('stdio[*] option cannot be an async iterable of objects - sync', testAsyncIterableSync, foobarAsyncObjectGenerator(), 3);11281const testIterableError = async (t, fdNumber) => {82 const {originalMessage} = await t.throwsAsync(execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, throwingGenerator().transform())));113const 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};11786test('stdin option handles errors in iterables', testIterableError, 0);87test('stdio[*] option handles errors in iterables', testIterableError, 3);118test('stdin option handles errors in iterables', testIterableError, 0, execa);119test('stdio[*] option handles errors in iterables', testIterableError, 3, execa);120121const testIterableErrorSync = (t, fdNumber, execaMethod) => {122 t.throws(() => {123 execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, throwingGenerator().transform()));124 }, {message: 'Generator error'});125};126127test('stdin option handles errors in iterables - sync', testIterableErrorSync, 0, execaSync);128test('stdio[*] option handles errors in iterables - sync', testIterableErrorSync, 3, execaSync);129130const testNoIterableOutput = (t, stdioOption, fdNumber, execaMethod) => {131 t.throws(() => {132 execaMethod('empty.js', getStdio(fdNumber, stdioOption));133 }, {message: /cannot be an iterable/});134};13595test('stdout option cannot be an array of strings', testNoIterableOutput, [stringArray], 1, execa);96test('stderr option cannot be an array of strings', testNoIterableOutput, [stringArray], 2, execa);97test('stdout option cannot be an array of strings - sync', testNoIterableOutput, [stringArray], 1, execaSync);98test('stderr option cannot be an array of strings - sync', testNoIterableOutput, [stringArray], 2, execaSync);136test('stdout option cannot be an array of strings', testNoIterableOutput, [foobarArray], 1, execa);137test('stderr option cannot be an array of strings', testNoIterableOutput, [foobarArray], 2, execa);138test('stdout option cannot be an array of strings - sync', testNoIterableOutput, [foobarArray], 1, execaSync);139test('stderr option cannot be an array of strings - sync', testNoIterableOutput, [foobarArray], 2, execaSync);140test('stdout option cannot be an iterable', testNoIterableOutput, stringGenerator(), 1, execa);141test('stderr option cannot be an iterable', testNoIterableOutput, stringGenerator(), 2, execa);142test('stdout option cannot be an iterable - sync', testNoIterableOutput, stringGenerator(), 1, execaSync);143test('stderr option cannot be an iterable - sync', testNoIterableOutput, stringGenerator(), 2, execaSync);
7 unmodified lines
151 t.true(stdout.startsWith('foo'));152 t.deepEqual(await iterable.next(), {value: undefined, done: true});153});154114const testMultipleIterable = async (t, fdNumber) => {115 const {stdout} = await execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stringGenerator(), asyncGenerator()]));116 t.is(stdout, 'foobarfoobar');155const 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};163119test('stdin option can be multiple iterables', testMultipleIterable, 0);120test('stdio[*] option can be multiple iterables', testMultipleIterable, 3);164test('stdin option can be multiple iterables', testMultipleIterable, [stringGenerator(), stringGenerator()], 0, execa);165test('stdio[*] option can be multiple iterables', testMultipleIterable, [stringGenerator(), stringGenerator()], 3, execa);166test('stdin option can be multiple iterables - sync', testMultipleIterable, [stringGenerator(), stringGenerator()], 0, execaSync);167test('stdin option can be multiple mixed iterables', testMultipleIterable, [stringGenerator(), binaryGenerator()], 0, execa);168test('stdio[*] option can be multiple mixed iterables', testMultipleIterable, [stringGenerator(), binaryGenerator()], 3, execa);169test('stdin option can be multiple mixed iterables - sync', testMultipleIterable, [stringGenerator(), binaryGenerator()], 0, execaSync);170test('stdin option can be sync/async mixed iterables', testMultipleIterable, [stringGenerator(), asyncGenerator()], 0, execa);171test('stdio[*] option can be sync/async mixed iterables', testMultipleIterable, [stringGenerator(), asyncGenerator()], 3, execa);172173test('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 lines
modified:test/stdio/sync.js+1 added
53 unmodified lines
54 t.true(message.includes(expectedMessage));55};5657test('Cannot use Uint8Array with stdio[*], sync', testFd3InputSync, new Uint8Array(), getFd3InputMessage('a Uint8Array'));58test('Cannot use iterable with stdio[*], sync', testFd3InputSync, [[]], getFd3InputMessage('an iterable'));
modified:index.d.ts+8 added-5 removed
67 unmodified lines
68 | WebTransform69 | TransformStream>;7071// Synchronous iterables excluding strings, Uint8Arrays and Arrays72type IterableObject<IsArray extends boolean = boolean> = Iterable<unknown>72type 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 line
81 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>;8889type OutputStdioOption<90 IsSync extends boolean = boolean,91 IsArray extends boolean = boolean,
1309 unmodified lines
1401Same as `execa()` but synchronous.14021403Returns 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.14041402Cannot 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.1405Cannot 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.14061407@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` object
105 unmodified lines
1515Same as `execaCommand()` but synchronous.15161517Returns 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.15181516Cannot 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.1519Cannot 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.15201521@param command - The program/script to execute and its arguments.1522@returns A `subprocessResult` object1523@throws A `subprocessResult` error
128 unmodified lines
modified:index.test-d.ts+18 added-18 removed
2010 unmodified lines
2011expectNotAssignable<StdioOptionSync>(invalidFileObject);2012expectNotAssignable<StdioOption>([invalidFileObject]);2013expectNotAssignable<StdioOptionSync>([invalidFileObject]);2014execa('unicorns', {stdin: [stringArray]});2015expectError(execaSync('unicorns', {stdin: [stringArray]}));2015execaSync('unicorns', {stdin: [stringArray]});2016expectError(execa('unicorns', {stdout: [stringArray]}));2017expectError(execaSync('unicorns', {stdout: [stringArray]}));2018expectError(execa('unicorns', {stderr: [stringArray]}));2019expectError(execaSync('unicorns', {stderr: [stringArray]}));
1 unmodified line
2021expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [stringArray]]}));2022execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [[stringArray]]]});2023expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [[stringArray]]]}));2024expectAssignable<StdinOption>([stringArray]);2025expectNotAssignable<StdinOptionSync>([stringArray]);2025expectAssignable<StdinOptionSync>([stringArray]);2026expectNotAssignable<StdoutStderrOption>([stringArray]);2027expectNotAssignable<StdoutStderrOptionSync>([stringArray]);2028expectAssignable<StdioOption>([stringArray]);2029expectNotAssignable<StdioOptionSync>([stringArray]);2029expectAssignable<StdioOptionSync>([stringArray]);2030execa('unicorns', {stdin: [binaryArray]});2031expectError(execaSync('unicorns', {stdin: [binaryArray]}));2031execaSync('unicorns', {stdin: [binaryArray]});2032expectError(execa('unicorns', {stdout: [binaryArray]}));2033expectError(execaSync('unicorns', {stdout: [binaryArray]}));2034expectError(execa('unicorns', {stderr: [binaryArray]}));2035expectError(execaSync('unicorns', {stderr: [binaryArray]}));
1 unmodified line
2037expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [binaryArray]]}));2038execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [[binaryArray]]]});2039expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [[binaryArray]]]}));2040expectAssignable<StdinOption>([binaryArray]);2041expectNotAssignable<StdinOptionSync>([binaryArray]);2041expectAssignable<StdinOptionSync>([binaryArray]);2042expectNotAssignable<StdoutStderrOption>([binaryArray]);2043expectNotAssignable<StdoutStderrOptionSync>([binaryArray]);2044expectAssignable<StdioOption>([binaryArray]);2045expectNotAssignable<StdioOptionSync>([binaryArray]);2045expectAssignable<StdioOptionSync>([binaryArray]);2046execa('unicorns', {stdin: [objectArray]});2047expectError(execaSync('unicorns', {stdin: [objectArray]}));2048expectError(execa('unicorns', {stdout: [objectArray]}));2049expectError(execaSync('unicorns', {stdout: [objectArray]}));
9 unmodified lines
2059expectNotAssignable<StdoutStderrOptionSync>([objectArray]);2060expectAssignable<StdioOption>([objectArray]);2061expectNotAssignable<StdioOptionSync>([objectArray]);2062execa('unicorns', {stdin: stringIterable});2063expectError(execaSync('unicorns', {stdin: stringIterable}));2063execaSync('unicorns', {stdin: stringIterable});2064execa('unicorns', {stdin: [stringIterable]});2065expectError(execaSync('unicorns', {stdin: [stringIterable]}));2065execaSync('unicorns', {stdin: [stringIterable]});2066expectError(execa('unicorns', {stdout: stringIterable}));2067expectError(execaSync('unicorns', {stdout: stringIterable}));2068expectError(execa('unicorns', {stdout: [stringIterable]}));2069expectError(execaSync('unicorns', {stdout: [stringIterable]}));
7 unmodified lines
2077expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', stringIterable]}));2078execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [stringIterable]]});2079expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [stringIterable]]}));2080expectAssignable<StdinOption>(stringIterable);2081expectNotAssignable<StdinOptionSync>(stringIterable);2081expectAssignable<StdinOptionSync>(stringIterable);2082expectAssignable<StdinOption>([stringIterable]);2083expectNotAssignable<StdinOptionSync>([stringIterable]);2083expectAssignable<StdinOptionSync>([stringIterable]);2084expectNotAssignable<StdoutStderrOption>(stringIterable);2085expectNotAssignable<StdoutStderrOptionSync>(stringIterable);2086expectNotAssignable<StdoutStderrOption>([stringIterable]);2087expectNotAssignable<StdoutStderrOptionSync>([stringIterable]);2088expectAssignable<StdioOption>(stringIterable);2089expectNotAssignable<StdioOptionSync>(stringIterable);2089expectAssignable<StdioOptionSync>(stringIterable);2090expectAssignable<StdioOption>([stringIterable]);2091expectNotAssignable<StdioOptionSync>([stringIterable]);2091expectAssignable<StdioOptionSync>([stringIterable]);2092execa('unicorns', {stdin: binaryIterable});2093expectError(execaSync('unicorns', {stdin: binaryIterable}));2093execaSync('unicorns', {stdin: binaryIterable});2094execa('unicorns', {stdin: [binaryIterable]});2095expectError(execaSync('unicorns', {stdin: [binaryIterable]}));2095execaSync('unicorns', {stdin: [binaryIterable]});2096expectError(execa('unicorns', {stdout: binaryIterable}));2097expectError(execaSync('unicorns', {stdout: binaryIterable}));2098expectError(execa('unicorns', {stdout: [binaryIterable]}));2099expectError(execaSync('unicorns', {stdout: [binaryIterable]}));
7 unmodified lines
2107expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', binaryIterable]}));2108execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [binaryIterable]]});2109expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [binaryIterable]]}));2110expectAssignable<StdinOption>(binaryIterable);2111expectNotAssignable<StdinOptionSync>(binaryIterable);2111expectAssignable<StdinOptionSync>(binaryIterable);2112expectAssignable<StdinOption>([binaryIterable]);2113expectNotAssignable<StdinOptionSync>([binaryIterable]);2113expectAssignable<StdinOptionSync>([binaryIterable]);2114expectNotAssignable<StdoutStderrOption>(binaryIterable);2115expectNotAssignable<StdoutStderrOptionSync>(binaryIterable);2116expectNotAssignable<StdoutStderrOption>([binaryIterable]);2117expectNotAssignable<StdoutStderrOptionSync>([binaryIterable]);2118expectAssignable<StdioOption>(binaryIterable);2119expectNotAssignable<StdioOptionSync>(binaryIterable);2119expectAssignable<StdioOptionSync>(binaryIterable);2120expectAssignable<StdioOption>([binaryIterable]);2121expectNotAssignable<StdioOptionSync>([binaryIterable]);2121expectAssignable<StdioOptionSync>([binaryIterable]);2122execa('unicorns', {stdin: objectIterable});2123expectError(execaSync('unicorns', {stdin: objectIterable}));2124execa('unicorns', {stdin: [objectIterable]});2125expectError(execaSync('unicorns', {stdin: [objectIterable]}));
1546 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) 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.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 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.323324#### $(file, arguments?, options?)325326`file`: `string | URL`\
899 unmodified lines