Add support for transforms with `execaSync()` (#945)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent f744f7d · Browse files · 42 files·+1615 added−898 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
42 files+1615 added−898 removed
- tests:+1160 added−613 removed
- other:+455 added−285 removed
Provenance
- Commit
c5f9f09- Tree
ba28154- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
f744f7d
42 files changed+1615 added−898 removed
modified:lib/arguments/template.js+2 added-1 removed
1123456127 unmodified linesExpand allimport {isUint8Array, uint8ArrayToString, isSubprocess} from '../utils.js';import {isUint8Array, uint8ArrayToString} from '../stdio/uint-array.js';import {isSubprocess} from '../utils.js';
export const isTemplateString = templates => Array.isArray(templates) && Array.isArray(templates.raw);
export const parseTemplates = (templates, expressions) => {127 unmodified linesExpand allmodified:lib/exit/code.js+1 added-1 removed
9 unmodified lines1011121314141516171810 unmodified lines9 unmodified lines return [exitCode, signal];};
export const getSyncExitResult = ({error, status: exitCode, signal}) => ({ error: getSyncError(error, exitCode, signal), resultError: getSyncError(error, exitCode, signal), exitCode, signal,});
10 unmodified linesmodified:lib/return/error.js+1 added-1 removed
1 import {signalsByName} from 'human-signals';2 import stripFinalNewline from 'strip-final-newline';3-import {isUint8Array, uint8ArrayToString} from '../utils.js';3+import {isUint8Array, uint8ArrayToString} from '../stdio/uint-array.js';4 import {fixCwdError} from '../arguments/cwd.js';5 import {escapeLines} from '../arguments/escape.js';6 import {getDurationMs} from './duration.js';7 import {getFinalError, DiscardedError, isExecaError} from './cause.js';189 unmodified linesmodified:lib/return/output.js-6 removed
11323453 unmodified lines910111215161718131415168 unmodified linesimport {Buffer} from 'node:buffer';import stripFinalNewline from 'strip-final-newline';import {bufferToUint8Array} from '../utils.js';import {logFinalResult} from '../verbose/complete.js';
export const handleOutput = (options, value) => { if (value === undefined || value === null) {3 unmodified lines if (Array.isArray(value)) { return value; }
if (Buffer.isBuffer(value)) { value = bufferToUint8Array(value); }
return options.stripFinalNewline ? stripFinalNewline(value) : value;};
export const handleResult = (result, verboseInfo, {reject}) => {8 unmodified linesmodified:lib/stdio/async.js+1 added
15 unmodified lines16 };17 18 const addProperties = {19 generator: generatorToDuplexStream,20+ asyncGenerator: generatorToDuplexStream,21 nodeStream: ({value}) => ({stream: value}),22 webTransform({value: {transform, writableObjectMode, readableObjectMode}}) {23 const objectMode = writableObjectMode || readableObjectMode;24 const stream = Duplex.fromWeb(transform, {objectMode});91 unmodified linesmodified:lib/stdio/direction.js+1 added
29 unmodified lines30 31 // `string` can only be added through the `input` option, i.e. does not need to be handled here32 const guessStreamDirection = {33 generator: anyDirection,34+ asyncGenerator: anyDirection,35 fileUrl: anyDirection,36 filePath: anyDirection,37 iterable: alwaysInput,38 asyncIterable: alwaysInput,43 unmodified linesmodified:lib/stdio/encoding-final.js+3 added-4 removed
1 import {StringDecoder} from 'node:string_decoder';2 3 // Apply the `encoding` option using an implicit generator.4 // This encodes the final output of `stdout`/`stderr`.5-export const handleStreamsEncoding = ({options: {encoding}, isSync, direction, optionName, objectMode}) => {6- if (!shouldEncodeOutput({encoding, isSync, direction, objectMode})) {5+export const handleStreamsEncoding = ({options: {encoding}, direction, optionName, objectMode}) => {6+ if (!shouldEncodeOutput({encoding, direction, objectMode})) {7 return [];8 }9 10 const stringDecoder = new StringDecoder(encoding);7 unmodified lines18 optionName,19 }];20 };21 22-const shouldEncodeOutput = ({encoding, isSync, direction, objectMode}) => direction === 'output'22+const shouldEncodeOutput = ({encoding, direction, objectMode}) => direction === 'output'23 && encoding !== 'utf8'24 && encoding !== 'buffer'25- && !isSync25 && !objectMode;26 27 const encodingStringGenerator = function * (stringDecoder, chunk) {28 yield stringDecoder.write(chunk);8 unmodified linesmodified:lib/stdio/encoding-transform.js+13 added-4 removed
1 import {Buffer} from 'node:buffer';2+import {isUint8Array} from './uint-array.js';3 4 /*5 When using generators, add an internal generator that converts chunks from `Buffer` to `string` or `Uint8Array`.6 This allows generator functions to operate with those types instead.11 unmodified lines18 return;19 }20 21 if (binary) {21- return {transform: encodingUint8ArrayGenerator};22+ return {transform: encodingUint8ArrayGenerator.bind(undefined, new TextEncoder())};23 }24 25 const textDecoder = new TextDecoder();26 return {1 unmodified line28 final: encodingStringFinal.bind(undefined, textDecoder),29 };30 };31 31-const encodingUint8ArrayGenerator = function * (chunk) {32- yield Buffer.isBuffer(chunk) ? new Uint8Array(chunk) : chunk;32+const encodingUint8ArrayGenerator = function * (textEncoder, chunk) {33+ if (Buffer.isBuffer(chunk)) {34+ yield new Uint8Array(chunk);35+ } else if (typeof chunk === 'string') {36+ yield textEncoder.encode(chunk);37+ } else {38+ yield chunk;39+ }40 };41 42 const encodingStringGenerator = function * (textDecoder, chunk) {36- yield Buffer.isBuffer(chunk) ? textDecoder.decode(chunk, {stream: true}) : chunk;43+ yield Buffer.isBuffer(chunk) || isUint8Array(chunk)44+ ? textDecoder.decode(chunk, {stream: true})45+ : chunk;46 };47 48 const encodingStringFinal = function * (textDecoder) {49 const lastChunk = textDecoder.decode();4 unmodified linesmodified:lib/stdio/generator.js+29 added-8 removed
1 import isPlainObj from 'is-plain-obj';2 import {BINARY_ENCODINGS} from '../arguments/encoding.js';3-import {generatorsToTransform} from './transform.js';3+import {generatorsToTransform, runTransformSync} from './transform.js';4 import {getEncodingTransformGenerator} from './encoding-transform.js';5 import {getSplitLinesGenerator, getAppendNewlineGenerator} from './split.js';6 import {pipeStreams} from './pipeline.js';7 import {isAsyncGenerator} from './type.js';8-import {getValidateTransformReturn} from './validate.js';8+import {getValidateTransformInput, getValidateTransformReturn} from './validate.js';9 10 export const getObjectMode = (stdioItems, optionName, direction, options) => {11 const transforms = getTransforms(stdioItems, optionName, direction, options);12 if (transforms.length === 0) {19 unmodified lines32 33 return sortTransforms(newTransforms, direction);34 };35 36-export const TRANSFORM_TYPES = new Set(['generator', 'duplex', 'webTransform']);36+export const TRANSFORM_TYPES = new Set(['generator', 'asyncGenerator', 'duplex', 'webTransform']);37 38 const normalizeTransform = ({stdioItem, stdioItem: {type}, index, newTransforms, optionName, direction, encoding}) => {39 if (type === 'duplex') {40 return normalizeDuplex({stdioItem, optionName});98 unmodified lines139 140 Chunks are currently processed serially. We could add a `concurrency` option to parallelize in the future.141 */142 export const generatorToDuplexStream = ({143+ value,144+ value: {transform, final, writableObjectMode, readableObjectMode},145+ forceEncoding,146+ optionName,147+}) => {148+ const generators = addInternalGenerators({value, forceEncoding, optionName});149+ const transformAsync = isAsyncGenerator(transform);150+ const finalAsync = isAsyncGenerator(final);151+ const stream = generatorsToTransform(generators, {transformAsync, finalAsync, writableObjectMode, readableObjectMode});152+ return {stream};153+};154+155+export const getGenerators = allStdioItems => allStdioItems.filter(({type}) => type === 'generator');156+157+export const runGeneratorsSync = (chunks, generators) => {158+ for (const {value, optionName} of generators) {159+ const generators = addInternalGenerators({value, forceEncoding: false, optionName});160+ chunks = runTransformSync(generators, chunks);161+ }162+163+ return chunks;164+};165+166+const addInternalGenerators = ({167 value: {transform, final, binary, writableObjectMode, readableObjectMode, preserveNewlines},168 forceEncoding,169 optionName,170 }) => {171 const state = {};148- const generators = [172+ return [173+ {transform: getValidateTransformInput(writableObjectMode, optionName)},174 getEncodingTransformGenerator(binary, writableObjectMode, forceEncoding),175 getSplitLinesGenerator({binary, preserveNewlines, writableObjectMode, state}),176 {transform, final},177 {transform: getValidateTransformReturn(readableObjectMode, optionName)},178 getAppendNewlineGenerator({binary, preserveNewlines, readableObjectMode, state}),179 ].filter(Boolean);155- const transformAsync = isAsyncGenerator(transform);156- const finalAsync = isAsyncGenerator(final);157- const stream = generatorsToTransform(generators, {transformAsync, finalAsync, writableObjectMode, readableObjectMode});158- return {stream};180 };181 182 // `subprocess.stdin|stdout|stderr|stdio` is directly mutated.183 export const pipeTransform = (subprocess, stream, direction, fdNumber) => {15 unmodified linesmodified:lib/stdio/handle.js+25 added-15 removed
25 unmodified lines26 const outputLines = [];27 const optionName = getOptionName(fdNumber);28 const stdioItems = initializeStdioItems({stdioOption, fdNumber, options, isSync, optionName});29 const direction = getStreamDirection(stdioItems, fdNumber, optionName);30+ const objectMode = getObjectMode(stdioItems, optionName, direction, options);31+ validateFileObjectMode(stdioItems, objectMode);30- const normalizedStdioItems = normalizeStdioItems({stdioItems, fdNumber, optionName, addProperties, options, isSync, direction, stdioState, verboseInfo, outputLines});32+ const normalizedStdioItems = normalizeStdioItems({stdioItems, fdNumber, optionName, addProperties, options, isSync, direction, stdioState, verboseInfo, outputLines, objectMode});33 return {fdNumber, direction, outputLines, stdioItems: normalizedStdioItems};34 };35 36 const getOptionName = fdNumber => KNOWN_OPTION_NAMES[fdNumber] ?? `stdio[${fdNumber}]`;19 unmodified lines56 optionName,57 });58 59 const filterDuplicates = stdioItems => stdioItems.filter((stdioItemOne, indexOne) =>58- stdioItems.every((stdioItemTwo, indexTwo) =>59- stdioItemOne.value !== stdioItemTwo.value || indexOne >= indexTwo || stdioItemOne.type === 'generator'));60+ stdioItems.every((stdioItemTwo, indexTwo) => stdioItemOne.value !== stdioItemTwo.value61+ || indexOne >= indexTwo62+ || stdioItemOne.type === 'generator'63+ || stdioItemOne.type === 'asyncGenerator'));64 65 const validateStdioArray = (stdioItems, isStdioArray, optionName) => {66 if (stdioItems.length === 0) {67 throw new TypeError(`The \`${optionName}\` option must not be an empty array.`);30 unmodified lines98 throw new TypeError(`The \`${optionName}: { file: '...' }\` option must be used instead of \`${optionName}: '...'\`.`);99 }100 };101 98-const normalizeStdioItems = ({stdioItems, fdNumber, optionName, addProperties, options, isSync, direction, stdioState, verboseInfo, outputLines}) => {99- const allStdioItems = addInternalStdioItems({stdioItems, fdNumber, optionName, options, isSync, direction, stdioState, verboseInfo, outputLines});102+const normalizeStdioItems = ({stdioItems, fdNumber, optionName, addProperties, options, isSync, direction, stdioState, verboseInfo, outputLines, objectMode}) => {103+ const allStdioItems = addInternalStdioItems({stdioItems, fdNumber, optionName, options, isSync, direction, stdioState, verboseInfo, outputLines, objectMode});104 const normalizedStdioItems = normalizeTransforms(allStdioItems, optionName, direction, options);105 return normalizedStdioItems.map(stdioItem => addStreamProperties(stdioItem, addProperties, direction));106 };107 104-const addInternalStdioItems = ({stdioItems, fdNumber, optionName, options, isSync, direction, stdioState, verboseInfo, outputLines}) => {105- if (!willPipeFileDescriptor(stdioItems)) {106- return stdioItems;107- }108-109- const objectMode = getObjectMode(stdioItems, optionName, direction, options);110- return [108+const addInternalStdioItems = ({stdioItems, fdNumber, optionName, options, isSync, direction, stdioState, verboseInfo, outputLines, objectMode}) => willPipeFileDescriptor(stdioItems)109+ ? [110 ...stdioItems,112- ...handleStreamsEncoding({options, isSync, direction, optionName, objectMode}),111+ ...handleStreamsEncoding({options, direction, optionName, objectMode}),112 ...handleStreamsVerbose({stdioItems, options, isSync, stdioState, verboseInfo, fdNumber, optionName}),113 ...handleStreamsLines({options, isSync, direction, optionName, objectMode, outputLines}),115- ];116-};114+ ]115+ : stdioItems;116 117 // Some `stdio` values require Execa to create streams.118 // For example, file paths create file read/write streams.119 // Those transformations are specified in `addProperties`, which is both direction-specific and type-specific.120 const addStreamProperties = (stdioItem, addProperties, direction) => ({121 ...stdioItem,122 ...addProperties[direction][stdioItem.type](stdioItem),123 });124+125+const validateFileObjectMode = (stdioItems, objectMode) => {126+ if (!objectMode) {127+ return;128+ }129+130+ const fileStdioItem = stdioItems.find(({type}) => type === 'fileUrl' || type === 'filePath');131+ if (fileStdioItem !== undefined) {132+ throw new TypeError(`The \`${fileStdioItem.optionName}\` option cannot use both files and transforms in objectMode.`);133+ }134+};added:lib/stdio/input-sync.js+47 added
1+import {joinToUint8Array, isUint8Array} from './uint-array.js';2+import {TYPE_TO_MESSAGE} from './type.js';3+import {getGenerators, runGeneratorsSync} from './generator.js';4+5+// Apply `stdin`/`input`/`inputFile` options, before spawning, in sync mode, by converting it to the `input` option6+export const addInputOptionsSync = (fileDescriptors, options) => {7+ for (const fdNumber of getInputFdNumbers(fileDescriptors)) {8+ addInputOptionSync(fileDescriptors, fdNumber, options);9+ }10+};11+12+const getInputFdNumbers = fileDescriptors => new Set(fileDescriptors13+ .filter(({direction}) => direction === 'input')14+ .map(({fdNumber}) => fdNumber));15+16+const addInputOptionSync = (fileDescriptors, fdNumber, options) => {17+ const selectedStdioItems = fileDescriptors18+ .filter(fileDescriptor => fileDescriptor.fdNumber === fdNumber)19+ .flatMap(({stdioItems}) => stdioItems);20+ const allStdioItems = selectedStdioItems.filter(({contents}) => contents !== undefined);21+ if (allStdioItems.length === 0) {22+ return;23+ }24+25+ if (fdNumber !== 0) {26+ const [{type, optionName}] = allStdioItems;27+ throw new TypeError(`Only the \`stdin\` option, not \`${optionName}\`, can be ${TYPE_TO_MESSAGE[type]} with synchronous methods.`);28+ }29+30+ const allContents = allStdioItems.map(({contents}) => contents);31+ const transformedContents = allContents.map(contents => applySingleInputGeneratorsSync(contents, selectedStdioItems));32+ options.input = joinToUint8Array(transformedContents);33+};34+35+const applySingleInputGeneratorsSync = (contents, selectedStdioItems) => {36+ const generators = getGenerators(selectedStdioItems).reverse();37+ const newContents = runGeneratorsSync(contents, generators);38+ validateSerializable(newContents);39+ return joinToUint8Array(newContents);40+};41+42+const validateSerializable = newContents => {43+ const invalidItem = newContents.find(item => typeof item !== 'string' && !isUint8Array(item));44+ if (invalidItem !== undefined) {45+ throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${invalidItem}.`);46+ }47+};modified:lib/stdio/input.js+1 added-1 removed
1 import {isReadableStream} from 'is-stream';2-import {isUint8Array} from '../utils.js';2+import {isUint8Array} from './uint-array.js';3 import {isUrl, isFilePathString} from './type.js';4 5 // Append the `stdin` option with the `input` and `inputFile` options6 export const handleInputOptions = ({input, inputFile}, fdNumber) => fdNumber === 044 unmodified linesadded:lib/stdio/output-sync.js+65 added
1+import {writeFileSync} from 'node:fs';2+import {joinToString, joinToUint8Array, bufferToUint8Array} from './uint-array.js';3+import {getGenerators, runGeneratorsSync} from './generator.js';4+5+// Apply `stdout`/`stderr` options, after spawning, in sync mode6+export const transformOutputSync = (fileDescriptors, {output}, options) => {7+ if (output === null) {8+ return {output: Array.from({length: 3})};9+ }10+11+ const state = {};12+ const transformedOutput = output.map((result, fdNumber) =>13+ transformOutputResultSync({result, fileDescriptors, fdNumber, options, state}));14+ return {output: transformedOutput, ...state};15+};16+17+const transformOutputResultSync = ({result, fileDescriptors, fdNumber, options, state}) => {18+ if (result === null) {19+ return result;20+ }21+22+ const allStdioItems = fileDescriptors23+ .filter(fileDescriptor => fileDescriptor.fdNumber === fdNumber && fileDescriptor.direction === 'output')24+ .flatMap(({stdioItems}) => stdioItems);25+ const uint8ArrayResult = bufferToUint8Array(result);26+ const generators = getGenerators(allStdioItems);27+ const chunks = runOutputGeneratorsSync([uint8ArrayResult], generators, state);28+ const transformedResult = serializeChunks(chunks, generators, options);29+30+ try {31+ if (state.error === undefined) {32+ writeToFiles(transformedResult, allStdioItems);33+ }34+35+ return transformedResult;36+ } catch (error) {37+ state.error = error;38+ return transformedResult;39+ }40+};41+42+const runOutputGeneratorsSync = (chunks, generators, state) => {43+ try {44+ return runGeneratorsSync(chunks, generators);45+ } catch (error) {46+ state.error = error;47+ return chunks;48+ }49+};50+51+const serializeChunks = (chunks, generators, {encoding}) => {52+ if (generators.at(-1)?.value?.readableObjectMode) {53+ return chunks;54+ }55+56+ return encoding === 'buffer' ? joinToUint8Array(chunks) : joinToString(chunks, true);57+};58+59+const writeToFiles = (transformedResult, allStdioItems) => {60+ for (const {type, path} of allStdioItems) {61+ if (type === 'fileUrl' || type === 'filePath') {62+ writeFileSync(path, transformedResult);63+ }64+ }65+};modified:lib/stdio/sync.js+5 added-69 removed
1-import {readFileSync, writeFileSync} from 'node:fs';1+import {readFileSync} from 'node:fs';2 import {isStream as isNodeStream} from 'is-stream';3-import {bufferToUint8Array, uint8ArrayToString, isUint8Array} from '../utils.js';3+import {bufferToUint8Array} from './uint-array.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 mode7+// Normalize `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, before spawning, in sync mode8 export const handleInputSync = (options, verboseInfo) => {9 const {fileDescriptors} = handleInput(addPropertiesSync, options, verboseInfo, true);10 validateStdioArraysSync(fileDescriptors);11- addInputOptionsSync(fileDescriptors, options);11 return fileDescriptors;12 };13 14 const forbiddenIfSync = ({type, optionName}) => {12 unmodified lines27 throw new TypeError(`The \`${optionName}\` option cannot be ${value} with synchronous methods.`);28 };29 30 const addProperties = {32- generator: forbiddenIfSync,31+ generator() {},32+ asyncGenerator: forbiddenIfSync,33 webStream: forbiddenIfSync,34 nodeStream: forbiddenIfSync,35 webTransform: forbiddenIfSync,36 duplex: forbiddenIfSync,62 unmodified lines99 }100 };101 102 const OPTION_NAMES = new Set(['input', 'inputFile']);103-104-const addInputOptionsSync = (fileDescriptors, options) => {105- for (const fdNumber of getInputFdNumbers(fileDescriptors)) {106- addInputOptionSync(fileDescriptors, fdNumber, options);107- }108-};109-110-const getInputFdNumbers = fileDescriptors => new Set(fileDescriptors111- .filter(({direction}) => direction === 'input')112- .map(({fdNumber}) => fdNumber));113-114-const addInputOptionSync = (fileDescriptors, fdNumber, options) => {115- const allStdioItems = fileDescriptors116- .filter(fileDescriptor => fileDescriptor.fdNumber === fdNumber)117- .flatMap(({stdioItems}) => stdioItems)118- .filter(({contents}) => contents !== undefined);119- if (allStdioItems.length === 0) {120- return;121- }122-123- if (fdNumber !== 0) {124- const [{type, optionName}] = allStdioItems;125- 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);129- 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-143-const serializeContents = contents => typeof contents === 'string' ? contents : uint8ArrayToString(contents);144-145-// Handle `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, after spawning, in sync mode146-export const pipeOutputSync = (fileDescriptors, {output}) => {147- if (output === null) {148- return;149- }150-151- for (const {stdioItems, fdNumber, direction} of fileDescriptors) {152- for (const {type, path} of stdioItems) {153- pipeStdioItemSync(output[fdNumber], type, path, direction);154- }155- }156-};157-158-const pipeStdioItemSync = (result, type, path, direction) => {159- if (result === null || direction === 'input') {160- return;161- }162-163- if (type === 'fileUrl' || type === 'filePath') {164- writeFileSync(path, result);165- }166-};modified:lib/stdio/transform.js+6 added
96 unmodified lines97 done(error);98 }99 };100 101+// Run synchronous generators with `execaSync()`102+export const runTransformSync = (generators, chunks) => [103+ ...chunks.flatMap(chunk => [...transformChunkSync(chunk, generators, 0)]),104+ ...finalChunksSync(generators),105+];106+107 const transformChunkSync = function * (chunk, generators, index) {108 if (index === generators.length) {109 yield chunk;110 return;27 unmodified linesmodified:lib/stdio/type.js+8 added-3 removed
1 import {isStream as isNodeStream, isDuplexStream} from 'is-stream';2 import isPlainObj from 'is-plain-obj';3-import {isUint8Array} from '../utils.js';3+import {isUint8Array} from './uint-array.js';4 5 // The `stdin`/`stdout`/`stderr` option can be of many types. This detects it.6 export const getStdioItemType = (value, optionName) => {7- if (isGenerator(value)) {7+ if (isAsyncGenerator(value)) {8+ return 'asyncGenerator';9+ }10+11+ if (isSyncGenerator(value)) {12 return 'generator';13 }14 15 if (isUrl(value)) {88 unmodified lines104 105 checkBooleanOption(binary, `${optionName}.binary`);106 checkBooleanOption(objectMode, `${optionName}.objectMode`);107 104- return 'generator';108+ return isAsyncGenerator(transform) || isAsyncGenerator(final) ? 'asyncGenerator' : 'generator';109 };110 111 const checkBooleanOption = (value, optionName) => {112 if (value !== undefined && typeof value !== 'boolean') {31 unmodified lines144 145 // Convert types to human-friendly strings for error messages146 export const TYPE_TO_MESSAGE = {147 generator: 'a generator',148+ asyncGenerator: 'an async generator',149 fileUrl: 'a file URL',150 filePath: 'a file path string',151 webStream: 'a web stream',152 nodeStream: 'a Node.js stream',8 unmodified linesadded:lib/stdio/uint-array.js+59 added
1+import {Buffer} from 'node:buffer';2+3+export const isUint8Array = value => Object.prototype.toString.call(value) === '[object Uint8Array]' && !Buffer.isBuffer(value);4+5+export const bufferToUint8Array = buffer => new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);6+7+const textEncoder = new TextEncoder();8+const stringToUint8Array = string => textEncoder.encode(string);9+10+const textDecoder = new TextDecoder();11+export const uint8ArrayToString = uint8Array => textDecoder.decode(uint8Array);12+13+export const joinToString = (uint8ArraysOrStrings, areRelated) => {14+ if (uint8ArraysOrStrings.length === 1 && typeof uint8ArraysOrStrings[0] === 'string') {15+ return uint8ArraysOrStrings[0];16+ }17+18+ const strings = uint8ArraysToStrings(uint8ArraysOrStrings, areRelated);19+ return strings.join('');20+};21+22+const uint8ArraysToStrings = (uint8ArraysOrStrings, areRelated) => {23+ const decoder = new TextDecoder();24+ const strings = uint8ArraysOrStrings.map(uint8ArrayOrString => isUint8Array(uint8ArrayOrString)25+ ? decoder.decode(uint8ArrayOrString, {stream: areRelated})26+ : uint8ArrayOrString);27+ const finalString = decoder.decode();28+ return finalString === '' ? strings : [...strings, finalString];29+};30+31+export const joinToUint8Array = uint8ArraysOrStrings => {32+ if (uint8ArraysOrStrings.length === 1 && isUint8Array(uint8ArraysOrStrings[0])) {33+ return uint8ArraysOrStrings[0];34+ }35+36+ const uint8Arrays = stringsToUint8Arrays(uint8ArraysOrStrings);37+ const result = new Uint8Array(getJoinLength(uint8Arrays));38+39+ let index = 0;40+ for (const uint8Array of uint8Arrays) {41+ result.set(uint8Array, index);42+ index += uint8Array.length;43+ }44+45+ return result;46+};47+48+const stringsToUint8Arrays = uint8ArraysOrStrings => uint8ArraysOrStrings.map(uint8ArrayOrString => typeof uint8ArrayOrString === 'string'49+ ? stringToUint8Array(uint8ArrayOrString)50+ : uint8ArrayOrString);51+52+const getJoinLength = uint8Arrays => {53+ let joinLength = 0;54+ for (const uint8Array of uint8Arrays) {55+ joinLength += uint8Array.length;56+ }57+58+ return joinLength;59+};modified:lib/stdio/validate.js+13 added-1 removed
1 import {Buffer} from 'node:buffer';2-import {isUint8Array} from '../utils.js';2+import {isUint8Array} from './uint-array.js';3 4+export const getValidateTransformInput = (writableObjectMode, optionName) => writableObjectMode5+ ? undefined6+ : validateStringTransformInput.bind(undefined, optionName);7+8+const validateStringTransformInput = function * (optionName, chunk) {9+ if (typeof chunk !== 'string' && !isUint8Array(chunk) && !Buffer.isBuffer(chunk)) {10+ throw new TypeError(`The \`${optionName}\` option's transform must use "objectMode: true" to receive as input: ${typeof chunk}.`);11+ }12+13+ yield chunk;14+};15+16 export const getValidateTransformReturn = (readableObjectMode, optionName) => readableObjectMode17 ? validateObjectTransformReturn.bind(undefined, optionName)18 : validateStringTransformReturn.bind(undefined, optionName);19 23 unmodified linesmodified:lib/sync.js+20 added-10 removed
1 import {spawnSync} from 'node:child_process';2 import {handleCommand, handleOptions} from './arguments/options.js';3 import {makeError, makeEarlyError, makeSuccessResult} from './return/error.js';4 import {handleOutput, handleResult} from './return/output.js';5-import {handleInputSync, pipeOutputSync} from './stdio/sync.js';5+import {handleInputSync} from './stdio/sync.js';6+import {addInputOptionsSync} from './stdio/input-sync.js';7+import {transformOutputSync} from './stdio/output-sync.js';8 import {logEarlyResult} from './verbose/complete.js';9 import {getSyncExitResult} from './exit/code.js';10 11 export const execaCoreSync = (rawFile, rawArgs, rawOptions) => {37 unmodified lines49 throw new TypeError(`The "${value}" option cannot be used with synchronous methods.`);50 };51 52 const spawnSubprocessSync = ({file, args, options, command, escapedCommand, fileDescriptors, startTime}) => {51- let syncResult;52- try {53- syncResult = spawnSync(file, args, options);54- } catch (error) {55- return makeEarlyError({error, command, escapedCommand, fileDescriptors, options, startTime, isSync: true});53+ const syncResult = runSubprocessSync({file, args, options, command, escapedCommand, fileDescriptors, startTime});54+ if (syncResult.failed) {55+ return syncResult;56 }57 58- const {error, exitCode, signal} = getSyncExitResult(syncResult);59- pipeOutputSync(fileDescriptors, syncResult);60-61- const output = syncResult.output || Array.from({length: 3});58+ const {resultError, exitCode, signal} = getSyncExitResult(syncResult);59+ const {output, error = resultError} = transformOutputSync(fileDescriptors, syncResult, options);60 const stdio = output.map(stdioOutput => handleOutput(options, stdioOutput));61 return getSyncResult({error, exitCode, signal, stdio, options, command, escapedCommand, startTime});62 };63 64+const runSubprocessSync = ({file, args, options, command, escapedCommand, fileDescriptors, startTime}) => {65+ try {66+ addInputOptionsSync(fileDescriptors, options);67+ const normalizedOptions = normalizeSpawnSyncOptions(options);68+ return spawnSync(file, args, normalizedOptions);69+ } catch (error) {70+ return makeEarlyError({error, command, escapedCommand, fileDescriptors, options, startTime, isSync: true});71+ }72+};73+74+const normalizeSpawnSyncOptions = ({encoding, ...options}) => ({...options, encoding: 'buffer'});75+76 const getSyncResult = ({error, exitCode, signal, stdio, options, command, escapedCommand, startTime}) => error === undefined77 ? makeSuccessResult({command, escapedCommand, stdio, options, startTime})78 : makeError({79 error,11 unmodified linesmodified:lib/utils.js-8 removed
1-import {Buffer} from 'node:buffer';1 import {ChildProcess} from 'node:child_process';2 import {addAbortListener} from 'node:events';3 import process from 'node:process';4 6-export const isUint8Array = value => Object.prototype.toString.call(value) === '[object Uint8Array]' && !Buffer.isBuffer(value);7-8-export const bufferToUint8Array = buffer => new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);9-10-const textDecoder = new TextDecoder();11-export const uint8ArrayToString = uint8Array => textDecoder.decode(uint8Array);12-5 export const isStandardStream = stream => STANDARD_STREAMS.includes(stream);6 export const STANDARD_STREAMS = [process.stdin, process.stdout, process.stderr];7 export const STANDARD_STREAMS_ALIASES = ['stdin', 'stdout', 'stderr'];8 13 unmodified linesmodified:test/convert/loop.js+7 added-7 removed
131 unmodified lines132 await subprocess;133 };134 135 test('.iterable() uses Uint8Arrays with "binary: true"', testObjectMode, simpleChunksUint8Array, 'iterable', null, false, false, true);136-test('.iterable() uses strings with "binary: true" and .setEncoding("utf8")', testObjectMode, simpleChunks, 'iterable', 'utf8', false, false, true);137-test('.iterable() uses strings with "binary: true" and "encoding: buffer"', testObjectMode, simpleChunks, 'iterable', 'utf8', false, false, true, {encoding: 'buffer'});136+test('.iterable() uses Uint8Arrays with "binary: true" and .setEncoding("utf8")', testObjectMode, simpleChunksUint8Array, 'iterable', 'utf8', false, false, true);137+test('.iterable() uses Uint8Arrays with "binary: true", .setEncoding("utf8") and "encoding: buffer"', testObjectMode, simpleChunksUint8Array, 'iterable', 'utf8', false, false, true, {encoding: 'buffer'});138 test('.iterable() uses strings in objectMode with "binary: true" and object transforms', testObjectMode, foobarObjectChunks, 'iterable', null, true, true, true, {stdout: outputObjectGenerator()});139 test('.iterable() uses strings in objectMode with "binary: false"', testObjectMode, simpleLines, 'iterable', null, false, true, false);140 test('.iterable() uses strings in objectMode with "binary: false" and .setEncoding("utf8")', testObjectMode, simpleLines, 'iterable', 'utf8', false, true, false);141-test('.iterable() uses strings in objectMode with "binary: false" and "encoding: buffer"', testObjectMode, simpleChunks, 'iterable', 'utf8', false, true, false, {encoding: 'buffer'});141+test('.iterable() uses Uint8Arrays in objectMode with "binary: false", .setEncoding("utf8") and "encoding: buffer"', testObjectMode, simpleChunksUint8Array, 'iterable', 'utf8', false, true, false, {encoding: 'buffer'});142 test('.iterable() uses strings in objectMode with "binary: false" and object transforms', testObjectMode, foobarObjectChunks, 'iterable', null, true, true, false, {stdout: outputObjectGenerator()});143 test('.readable() uses Buffers with "binary: true"', testObjectMode, simpleChunksBuffer, 'readable', null, false, false, true);144 test('.readable() uses strings with "binary: true" and .setEncoding("utf8")', testObjectMode, simpleChunks, 'readable', 'utf8', false, false, true);145-test('.readable() uses strings with "binary: true" and "encoding: buffer"', testObjectMode, simpleChunks, 'readable', 'utf8', false, false, true, {encoding: 'buffer'});145+test('.readable() uses strings with "binary: true", .setEncoding("utf8") and "encoding: buffer"', testObjectMode, simpleChunks, 'readable', 'utf8', false, false, true, {encoding: 'buffer'});146 test('.readable() uses strings in objectMode with "binary: true" and object transforms', testObjectMode, foobarObjectChunks, 'readable', null, true, true, true, {stdout: outputObjectGenerator()});147 test('.readable() uses strings in objectMode with "binary: false"', testObjectMode, simpleLines, 'readable', null, false, true, false);148 test('.readable() uses strings in objectMode with "binary: false" and .setEncoding("utf8")', testObjectMode, simpleLines, 'readable', 'utf8', false, true, false);149-test('.readable() uses strings in objectMode with "binary: false" and "encoding: buffer"', testObjectMode, simpleChunks, 'readable', 'utf8', false, false, false, {encoding: 'buffer'});149+test('.readable() uses strings in objectMode with "binary: false", .setEncoding("utf8") and "encoding: buffer"', testObjectMode, simpleChunks, 'readable', 'utf8', false, false, false, {encoding: 'buffer'});150 test('.readable() uses strings in objectMode with "binary: false" and object transforms', testObjectMode, foobarObjectChunks, 'readable', null, true, true, false, {stdout: outputObjectGenerator()});151 test('.duplex() uses Buffers with "binary: true"', testObjectMode, simpleChunksBuffer, 'duplex', null, false, false, true);152 test('.duplex() uses strings with "binary: true" and .setEncoding("utf8")', testObjectMode, simpleChunks, 'duplex', 'utf8', false, false, true);153-test('.duplex() uses strings with "binary: true" and "encoding: buffer"', testObjectMode, simpleChunks, 'duplex', 'utf8', false, false, true, {encoding: 'buffer'});153+test('.duplex() uses strings with "binary: true", .setEncoding("utf8") and "encoding: buffer"', testObjectMode, simpleChunks, 'duplex', 'utf8', false, false, true, {encoding: 'buffer'});154 test('.duplex() uses strings in objectMode with "binary: true" and object transforms', testObjectMode, foobarObjectChunks, 'duplex', null, true, true, true, {stdout: outputObjectGenerator()});155 test('.duplex() uses strings in objectMode with "binary: false"', testObjectMode, simpleLines, 'duplex', null, false, true, false);156 test('.duplex() uses strings in objectMode with "binary: false" and .setEncoding("utf8")', testObjectMode, simpleLines, 'duplex', 'utf8', false, true, false);157-test('.duplex() uses strings in objectMode with "binary: false" and "encoding: buffer"', testObjectMode, simpleChunks, 'duplex', 'utf8', false, false, false, {encoding: 'buffer'});157+test('.duplex() uses strings in objectMode with "binary: false", .setEncoding("utf8") and "encoding: buffer"', testObjectMode, simpleChunks, 'duplex', 'utf8', false, false, false, {encoding: 'buffer'});158 test('.duplex() uses strings in objectMode with "binary: false" and object transforms', testObjectMode, foobarObjectChunks, 'duplex', null, true, true, false, {stdout: outputObjectGenerator()});159 160 const testObjectSplit = async (t, methodName) => {161 const subprocess = getSubprocess(methodName, foobarString, {stdout: getOutputGenerator(simpleFull)(true)});22 unmodified linesmodified:test/convert/writable.js+3 added-3 removed
22 unmodified lines23 import {foobarString, foobarBuffer, foobarObject, foobarObjectString} from '../helpers/input.js';24 import {prematureClose, fullReadableStdio} from '../helpers/stdio.js';25 import {26 throwingGenerator,27- GENERATOR_ERROR_REGEXP,27 serializeGenerator,28 noopAsyncGenerator,29 } from '../helpers/generator.js';30 import {defaultHighWaterMark, defaultObjectHighWaterMark} from '../helpers/stream.js';305 unmodified lines336 await assertSubprocessOutput(t, subprocess, expectedOutput);337 });338 339 const testPropagateError = async (t, methodName) => {340+ const cause = new Error(foobarString);341- const subprocess = getReadWriteSubprocess({stdin: throwingGenerator()});341+ const subprocess = getReadWriteSubprocess({stdin: throwingGenerator(cause)()});342 const stream = subprocess[methodName]();343 stream.end('.');344- await t.throwsAsync(finishedStream(stream), {message: GENERATOR_ERROR_REGEXP});344+ await assertStreamError(t, stream, {cause});345 };346 347 test('.writable() propagates write errors', testPropagateError, 'writable');348 test('.duplex() propagates write errors', testPropagateError, 'duplex');41 unmodified linesmodified:test/helpers/duplex.js+2 added-2 removed
45 unmodified lines46 export const uppercaseEncodingDuplex = (encoding, outerObjectMode) => getDuplex(buffer => buffer.toString().toUpperCase(), encoding, outerObjectMode);47 48 export const uppercaseBufferDuplex = uppercaseEncodingDuplex();49 50-export const throwingDuplex = getDuplex(() => {51- throw new Error('Generator error');50+export const throwingDuplex = cause => getDuplex(() => {51+ throw cause;52 });53 54 export const appendDuplex = getDuplex(string => `${string}${casedSuffix}`);55 4 unmodified linesmodified:test/helpers/generator.js+6 added-4 removed
85 unmodified lines86 yield string.toUpperCase();87 });88 89 // eslint-disable-next-line require-yield90-export const throwingGenerator = getGenerator(function * () {91- throw new Error('Generator error');90+export const throwingGenerator = error => getGenerator(function * () {91+ throw error;92 });93 94-export const GENERATOR_ERROR_REGEXP = /Generator error/;95-94 export const appendGenerator = getGenerator(function * (string) {95 yield `${string}${casedSuffix}`;96 });97 98+export const appendAsyncGenerator = getGenerator(async function * (string) {99+ yield `${string}${casedSuffix}`;100+});101+102 export const casedSuffix = 'k';103 104 export const resultGenerator = inputs => getGenerator(function * (input) {105 inputs.push(input);7 unmodified linesmodified:test/helpers/web-transform.js+2 added-2 removed
43 unmodified lines44 export const uppercaseBufferWebTransform = getWebTransform((string, controller) => {45 controller.enqueue(string.toString().toUpperCase());46 });47 48-export const throwingWebTransform = getWebTransform(() => {49- throw new Error('Generator error');48+export const throwingWebTransform = cause => getWebTransform(() => {49+ throw cause;50 });51 52 export const appendWebTransform = getWebTransform((string, controller) => {53 controller.enqueue(`${string}${casedSuffix}`);6 unmodified linesmodified:test/stdio/encoding-final.js+90 added-49 removed
6 unmodified lines7 import {execa, execaSync} from '../../index.js';8 import {setFixtureDir, FIXTURES_DIR} from '../helpers/fixtures-dir.js';9 import {fullStdio} from '../helpers/stdio.js';10 import {outputObjectGenerator, getOutputsGenerator, addNoopGenerator} from '../helpers/generator.js';11-import {foobarObject} from '../helpers/input.js';11+import {foobarString, foobarUint8Array, foobarObject, foobarHex} from '../helpers/input.js';12 13 const pExec = promisify(exec);14 15 setFixtureDir();81 unmodified lines97 test('can pass encoding "base64url" to stdio[*] - sync', checkEncoding, 'base64url', 3, execaSync);98 99 const foobarArray = ['fo', 'ob', 'ar', '..'];100 101-const testMultibyteCharacters = async (t, objectMode, addNoopTransform) => {102- const {stdout} = await execa('noop.js', {101+const testMultibyteCharacters = async (t, objectMode, addNoopTransform, execaMethod) => {102+ const {stdout} = await execaMethod('noop.js', {103 stdout: addNoopGenerator(getOutputsGenerator(foobarArray)(objectMode, true), addNoopTransform, objectMode),104 encoding: 'base64',105 });106 if (objectMode) {2 unmodified lines109 t.is(stdout, btoa(foobarArray.join('')));110 }111 };112 113-test('Handle multibyte characters', testMultibyteCharacters, false, false);114-test('Handle multibyte characters, noop transform', testMultibyteCharacters, false, true);115-test('Handle multibyte characters, with objectMode', testMultibyteCharacters, true, false);116-test('Handle multibyte characters, with objectMode, noop transform', testMultibyteCharacters, true, true);113+test('Handle multibyte characters', testMultibyteCharacters, false, false, execa);114+test('Handle multibyte characters, noop transform', testMultibyteCharacters, false, true, execa);115+test('Handle multibyte characters, with objectMode', testMultibyteCharacters, true, false, execa);116+test('Handle multibyte characters, with objectMode, noop transform', testMultibyteCharacters, true, true, execa);117+test('Handle multibyte characters, sync', testMultibyteCharacters, false, false, execaSync);118+test('Handle multibyte characters, noop transform, sync', testMultibyteCharacters, false, true, execaSync);119+test('Handle multibyte characters, with objectMode, sync', testMultibyteCharacters, true, false, execaSync);120+test('Handle multibyte characters, with objectMode, noop transform, sync', testMultibyteCharacters, true, true, execaSync);121 118-const testObjectMode = async (t, addNoopTransform) => {119- const {stdout} = await execa('noop.js', {stdout: addNoopGenerator(outputObjectGenerator(), addNoopTransform, true), encoding: 'base64'});122+const testObjectMode = async (t, addNoopTransform, execaMethod) => {123+ const {stdout} = await execaMethod('noop.js', {124+ stdout: addNoopGenerator(outputObjectGenerator(), addNoopTransform, true),125+ encoding: 'base64',126+ });127 t.deepEqual(stdout, [foobarObject]);128 };129 123-test('Other encodings work with transforms that return objects', testObjectMode, false);124-test('Other encodings work with transforms that return objects, noop transform', testObjectMode, true);130+test('Other encodings work with transforms that return objects', testObjectMode, false, execa);131+test('Other encodings work with transforms that return objects, noop transform', testObjectMode, true, execa);132+test('Other encodings work with transforms that return objects, sync', testObjectMode, false, execaSync);133+test('Other encodings work with transforms that return objects, noop transform, sync', testObjectMode, true, execaSync);134 135+// eslint-disable-next-line max-params126-const testIgnoredEncoding = async (t, stdoutOption, isUndefined, options) => {127- const {stdout} = await execa('empty.js', {stdout: stdoutOption, ...options});136+const testIgnoredEncoding = async (t, stdoutOption, isUndefined, options, execaMethod) => {137+ const {stdout} = await execaMethod('empty.js', {stdout: stdoutOption, ...options});138 t.is(stdout === undefined, isUndefined);139 };140 141 const base64Options = {encoding: 'base64'};142 const linesOptions = {lines: true};133-test('Is ignored with other encodings and "ignore"', testIgnoredEncoding, 'ignore', true, base64Options);134-test('Is ignored with other encodings and ["ignore"]', testIgnoredEncoding, ['ignore'], true, base64Options);135-test('Is ignored with other encodings and "ipc"', testIgnoredEncoding, 'ipc', true, base64Options);136-test('Is ignored with other encodings and ["ipc"]', testIgnoredEncoding, ['ipc'], true, base64Options);137-test('Is ignored with other encodings and "inherit"', testIgnoredEncoding, 'inherit', true, base64Options);138-test('Is ignored with other encodings and ["inherit"]', testIgnoredEncoding, ['inherit'], true, base64Options);139-test('Is ignored with other encodings and 1', testIgnoredEncoding, 1, true, base64Options);140-test('Is ignored with other encodings and [1]', testIgnoredEncoding, [1], true, base64Options);141-test('Is ignored with other encodings and process.stdout', testIgnoredEncoding, process.stdout, true, base64Options);142-test('Is ignored with other encodings and [process.stdout]', testIgnoredEncoding, [process.stdout], true, base64Options);143-test('Is not ignored with other encodings and "pipe"', testIgnoredEncoding, 'pipe', false, base64Options);144-test('Is not ignored with other encodings and ["pipe"]', testIgnoredEncoding, ['pipe'], false, base64Options);145-test('Is not ignored with other encodings and "overlapped"', testIgnoredEncoding, 'overlapped', false, base64Options);146-test('Is not ignored with other encodings and ["overlapped"]', testIgnoredEncoding, ['overlapped'], false, base64Options);147-test('Is not ignored with other encodings and ["inherit", "pipe"]', testIgnoredEncoding, ['inherit', 'pipe'], false, base64Options);148-test('Is not ignored with other encodings and undefined', testIgnoredEncoding, undefined, false, base64Options);149-test('Is not ignored with other encodings and null', testIgnoredEncoding, null, false, base64Options);150-test('Is ignored with "lines: true" and "ignore"', testIgnoredEncoding, 'ignore', true, linesOptions);151-test('Is ignored with "lines: true" and ["ignore"]', testIgnoredEncoding, ['ignore'], true, linesOptions);152-test('Is ignored with "lines: true" and "ipc"', testIgnoredEncoding, 'ipc', true, linesOptions);153-test('Is ignored with "lines: true" and ["ipc"]', testIgnoredEncoding, ['ipc'], true, linesOptions);154-test('Is ignored with "lines: true" and "inherit"', testIgnoredEncoding, 'inherit', true, linesOptions);155-test('Is ignored with "lines: true" and ["inherit"]', testIgnoredEncoding, ['inherit'], true, linesOptions);156-test('Is ignored with "lines: true" and 1', testIgnoredEncoding, 1, true, linesOptions);157-test('Is ignored with "lines: true" and [1]', testIgnoredEncoding, [1], true, linesOptions);158-test('Is ignored with "lines: true" and process.stdout', testIgnoredEncoding, process.stdout, true, linesOptions);159-test('Is ignored with "lines: true" and [process.stdout]', testIgnoredEncoding, [process.stdout], true, linesOptions);160-test('Is not ignored with "lines: true" and "pipe"', testIgnoredEncoding, 'pipe', false, linesOptions);161-test('Is not ignored with "lines: true" and ["pipe"]', testIgnoredEncoding, ['pipe'], false, linesOptions);162-test('Is not ignored with "lines: true" and "overlapped"', testIgnoredEncoding, 'overlapped', false, linesOptions);163-test('Is not ignored with "lines: true" and ["overlapped"]', testIgnoredEncoding, ['overlapped'], false, linesOptions);164-test('Is not ignored with "lines: true" and ["inherit", "pipe"]', testIgnoredEncoding, ['inherit', 'pipe'], false, linesOptions);165-test('Is not ignored with "lines: true" and undefined', testIgnoredEncoding, undefined, false, linesOptions);166-test('Is not ignored with "lines: true" and null', testIgnoredEncoding, null, false, linesOptions);167-test('Is ignored with "lines: true", other encodings and "ignore"', testIgnoredEncoding, 'ignore', true, {...base64Options, ...linesOptions});168-test('Is not ignored with "lines: true", other encodings and "pipe"', testIgnoredEncoding, 'pipe', false, {...base64Options, ...linesOptions});143+test('Is ignored with other encodings and "ignore"', testIgnoredEncoding, 'ignore', true, base64Options, execa);144+test('Is ignored with other encodings and ["ignore"]', testIgnoredEncoding, ['ignore'], true, base64Options, execa);145+test('Is ignored with other encodings and "ipc"', testIgnoredEncoding, 'ipc', true, base64Options, execa);146+test('Is ignored with other encodings and ["ipc"]', testIgnoredEncoding, ['ipc'], true, base64Options, execa);147+test('Is ignored with other encodings and "inherit"', testIgnoredEncoding, 'inherit', true, base64Options, execa);148+test('Is ignored with other encodings and ["inherit"]', testIgnoredEncoding, ['inherit'], true, base64Options, execa);149+test('Is ignored with other encodings and 1', testIgnoredEncoding, 1, true, base64Options, execa);150+test('Is ignored with other encodings and [1]', testIgnoredEncoding, [1], true, base64Options, execa);151+test('Is ignored with other encodings and process.stdout', testIgnoredEncoding, process.stdout, true, base64Options, execa);152+test('Is ignored with other encodings and [process.stdout]', testIgnoredEncoding, [process.stdout], true, base64Options, execa);153+test('Is not ignored with other encodings and "pipe"', testIgnoredEncoding, 'pipe', false, base64Options, execa);154+test('Is not ignored with other encodings and ["pipe"]', testIgnoredEncoding, ['pipe'], false, base64Options, execa);155+test('Is not ignored with other encodings and "overlapped"', testIgnoredEncoding, 'overlapped', false, base64Options, execa);156+test('Is not ignored with other encodings and ["overlapped"]', testIgnoredEncoding, ['overlapped'], false, base64Options, execa);157+test('Is not ignored with other encodings and ["inherit", "pipe"]', testIgnoredEncoding, ['inherit', 'pipe'], false, base64Options, execa);158+test('Is not ignored with other encodings and undefined', testIgnoredEncoding, undefined, false, base64Options, execa);159+test('Is not ignored with other encodings and null', testIgnoredEncoding, null, false, base64Options, execa);160+test('Is ignored with other encodings and "ignore", sync', testIgnoredEncoding, 'ignore', true, base64Options, execaSync);161+test('Is ignored with other encodings and ["ignore"], sync', testIgnoredEncoding, ['ignore'], true, base64Options, execaSync);162+test('Is ignored with other encodings and "inherit", sync', testIgnoredEncoding, 'inherit', true, base64Options, execaSync);163+test('Is ignored with other encodings and ["inherit"], sync', testIgnoredEncoding, ['inherit'], true, base64Options, execaSync);164+test('Is ignored with other encodings and 1, sync', testIgnoredEncoding, 1, true, base64Options, execaSync);165+test('Is ignored with other encodings and [1], sync', testIgnoredEncoding, [1], true, base64Options, execaSync);166+test('Is ignored with other encodings and process.stdout, sync', testIgnoredEncoding, process.stdout, true, base64Options, execaSync);167+test('Is ignored with other encodings and [process.stdout], sync', testIgnoredEncoding, [process.stdout], true, base64Options, execaSync);168+test('Is not ignored with other encodings and "pipe", sync', testIgnoredEncoding, 'pipe', false, base64Options, execaSync);169+test('Is not ignored with other encodings and ["pipe"], sync', testIgnoredEncoding, ['pipe'], false, base64Options, execaSync);170+test('Is not ignored with other encodings and undefined, sync', testIgnoredEncoding, undefined, false, base64Options, execaSync);171+test('Is not ignored with other encodings and null, sync', testIgnoredEncoding, null, false, base64Options, execaSync);172+test('Is ignored with "lines: true" and "ignore"', testIgnoredEncoding, 'ignore', true, linesOptions, execa);173+test('Is ignored with "lines: true" and ["ignore"]', testIgnoredEncoding, ['ignore'], true, linesOptions, execa);174+test('Is ignored with "lines: true" and "ipc"', testIgnoredEncoding, 'ipc', true, linesOptions, execa);175+test('Is ignored with "lines: true" and ["ipc"]', testIgnoredEncoding, ['ipc'], true, linesOptions, execa);176+test('Is ignored with "lines: true" and "inherit"', testIgnoredEncoding, 'inherit', true, linesOptions, execa);177+test('Is ignored with "lines: true" and ["inherit"]', testIgnoredEncoding, ['inherit'], true, linesOptions, execa);178+test('Is ignored with "lines: true" and 1', testIgnoredEncoding, 1, true, linesOptions, execa);179+test('Is ignored with "lines: true" and [1]', testIgnoredEncoding, [1], true, linesOptions, execa);180+test('Is ignored with "lines: true" and process.stdout', testIgnoredEncoding, process.stdout, true, linesOptions, execa);181+test('Is ignored with "lines: true" and [process.stdout]', testIgnoredEncoding, [process.stdout], true, linesOptions, execa);182+test('Is not ignored with "lines: true" and "pipe"', testIgnoredEncoding, 'pipe', false, linesOptions, execa);183+test('Is not ignored with "lines: true" and ["pipe"]', testIgnoredEncoding, ['pipe'], false, linesOptions, execa);184+test('Is not ignored with "lines: true" and "overlapped"', testIgnoredEncoding, 'overlapped', false, linesOptions, execa);185+test('Is not ignored with "lines: true" and ["overlapped"]', testIgnoredEncoding, ['overlapped'], false, linesOptions, execa);186+test('Is not ignored with "lines: true" and ["inherit", "pipe"]', testIgnoredEncoding, ['inherit', 'pipe'], false, linesOptions, execa);187+test('Is not ignored with "lines: true" and undefined', testIgnoredEncoding, undefined, false, linesOptions, execa);188+test('Is not ignored with "lines: true" and null', testIgnoredEncoding, null, false, linesOptions, execa);189+test('Is ignored with "lines: true", other encodings and "ignore"', testIgnoredEncoding, 'ignore', true, {...base64Options, ...linesOptions}, execa);190+test('Is not ignored with "lines: true", other encodings and "pipe"', testIgnoredEncoding, 'pipe', false, {...base64Options, ...linesOptions}, execa);191+192+// eslint-disable-next-line max-params193+const testEncodingInput = async (t, input, expectedStdout, encoding, execaMethod) => {194+ const {stdout} = await execaMethod('stdin.js', {input, encoding});195+ t.deepEqual(stdout, expectedStdout);196+};197+198+test('Can use string input', testEncodingInput, foobarString, foobarString, 'utf8', execa);199+test('Can use Uint8Array input', testEncodingInput, foobarUint8Array, foobarString, 'utf8', execa);200+test('Can use string input, encoding "buffer"', testEncodingInput, foobarString, foobarUint8Array, 'buffer', execa);201+test('Can use Uint8Array input, encoding "buffer"', testEncodingInput, foobarUint8Array, foobarUint8Array, 'buffer', execa);202+test('Can use string input, encoding "hex"', testEncodingInput, foobarString, foobarHex, 'hex', execa);203+test('Can use Uint8Array input, encoding "hex"', testEncodingInput, foobarUint8Array, foobarHex, 'hex', execa);204+test('Can use string input, sync', testEncodingInput, foobarString, foobarString, 'utf8', execaSync);205+test('Can use Uint8Array input, sync', testEncodingInput, foobarUint8Array, foobarString, 'utf8', execaSync);206+test('Can use string input, encoding "buffer", sync', testEncodingInput, foobarString, foobarUint8Array, 'buffer', execaSync);207+test('Can use Uint8Array input, encoding "buffer", sync', testEncodingInput, foobarUint8Array, foobarUint8Array, 'buffer', execaSync);208+test('Can use string input, encoding "hex", sync', testEncodingInput, foobarString, foobarHex, 'hex', execaSync);209+test('Can use Uint8Array input, encoding "hex", sync', testEncodingInput, foobarUint8Array, foobarHex, 'hex', execaSync);modified:test/stdio/encoding-transform.js+193 added-88 removed
1 import {Buffer} from 'node:buffer';2-import {scheduler} from 'node:timers/promises';2 import test from 'ava';4-import {execa} from '../../index.js';3+import {execa, execaSync} from '../../index.js';4 import {setFixtureDir} from '../helpers/fixtures-dir.js';5 import {getStdio} from '../helpers/stdio.js';6 import {foobarString, foobarUint8Array, foobarBuffer, foobarObject} from '../helpers/input.js';8-import {noopGenerator, getOutputGenerator, convertTransformToFinal} from '../helpers/generator.js';7+import {noopGenerator, getOutputGenerator, getOutputsGenerator, convertTransformToFinal} from '../helpers/generator.js';8 import {multibyteChar, multibyteString, multibyteUint8Array, breakingLength, brokenSymbol} from '../helpers/encoding.js';9 10 setFixtureDir();11 35 unmodified lines47 test('First generator argument is Uint8Array with encoding "buffer", with string writes, "binary: true"', testGeneratorFirstEncoding, foobarString, 'buffer', 'Uint8Array', false, true);48 test('First generator argument is Uint8Array with encoding "hex", with string writes, "binary: false"', testGeneratorFirstEncoding, foobarString, 'hex', 'Uint8Array', false, false);49 test('First generator argument is Uint8Array with encoding "hex", with string writes, "binary: true"', testGeneratorFirstEncoding, foobarString, 'hex', 'Uint8Array', false, true);50 51+// eslint-disable-next-line max-params52+const testGeneratorFirstEncodingSync = (t, input, encoding, expectedType, objectMode, binary) => {53+ const {stdout} = execaSync('stdin.js', {stdin: [[input], getTypeofGenerator(objectMode, binary)], encoding});54+ assertTypeofChunk(t, stdout, encoding, expectedType);55+};56+57+test('First generator argument is string with default encoding, with string writes, sync', testGeneratorFirstEncodingSync, foobarString, 'utf8', 'String', false);58+test('First generator argument is string with default encoding, with Uint8Array writes, sync', testGeneratorFirstEncodingSync, foobarUint8Array, 'utf8', 'String', false);59+test('First generator argument is Uint8Array with encoding "buffer", with string writes, sync', testGeneratorFirstEncodingSync, foobarString, 'buffer', 'Uint8Array', false);60+test('First generator argument is Uint8Array with encoding "buffer", with Uint8Array writes, sync', testGeneratorFirstEncodingSync, foobarUint8Array, 'buffer', 'Uint8Array', false);61+test('First generator argument is Uint8Array with encoding "hex", with string writes, sync', testGeneratorFirstEncodingSync, foobarString, 'hex', 'Uint8Array', false);62+test('First generator argument is Uint8Array with encoding "hex", with Uint8Array writes, sync', testGeneratorFirstEncodingSync, foobarUint8Array, 'hex', 'Uint8Array', false);63+test('First generator argument can be string with objectMode, sync', testGeneratorFirstEncodingSync, foobarString, 'utf8', 'String', true);64+test('First generator argument can be objects with objectMode, sync', testGeneratorFirstEncodingSync, foobarObject, 'utf8', 'Object', true);65+test('First generator argument is string with default encoding, with string writes, "binary: false", sync', testGeneratorFirstEncodingSync, foobarString, 'utf8', 'String', false, false);66+test('First generator argument is Uint8Array with default encoding, with string writes, "binary: true", sync', testGeneratorFirstEncodingSync, foobarString, 'utf8', 'Uint8Array', false, true);67+test('First generator argument is Uint8Array with encoding "buffer", with string writes, "binary: false", sync', testGeneratorFirstEncodingSync, foobarString, 'buffer', 'Uint8Array', false, false);68+test('First generator argument is Uint8Array with encoding "buffer", with string writes, "binary: true", sync', testGeneratorFirstEncodingSync, foobarString, 'buffer', 'Uint8Array', false, true);69+test('First generator argument is Uint8Array with encoding "hex", with string writes, "binary: false", sync', testGeneratorFirstEncodingSync, foobarString, 'hex', 'Uint8Array', false, false);70+test('First generator argument is Uint8Array with encoding "hex", with string writes, "binary: true", sync', testGeneratorFirstEncodingSync, foobarString, 'hex', 'Uint8Array', false, true);71+72 const testEncodingIgnored = async (t, encoding) => {73 const input = Buffer.from(foobarString).toString(encoding);74 const subprocess = execa('stdin.js', {stdin: noopGenerator(true)});75 subprocess.stdin.end(input, encoding);6 unmodified lines82 test('Write call encoding "hex" is ignored with objectMode', testEncodingIgnored, 'hex');83 test('Write call encoding "base64" is ignored with objectMode', testEncodingIgnored, 'base64');84 85 // eslint-disable-next-line max-params66-const testGeneratorNextEncoding = async (t, input, encoding, firstObjectMode, secondObjectMode, expectedType) => {67- const {stdout} = await execa('noop.js', ['other'], {86+const testGeneratorNextEncoding = async (t, input, encoding, firstObjectMode, secondObjectMode, expectedType, execaMethod) => {87+ const {stdout} = await execaMethod('noop.js', ['other'], {88 stdout: [89 getOutputGenerator(input)(firstObjectMode),90 getTypeofGenerator(secondObjectMode),91 ],2 unmodified lines94 const output = Array.isArray(stdout) ? stdout[0] : stdout;95 assertTypeofChunk(t, output, encoding, expectedType);96 };97 78-test('Next generator argument is string with default encoding, with string writes', testGeneratorNextEncoding, foobarString, 'utf8', false, false, 'String');79-test('Next generator argument is string with default encoding, with string writes, objectMode first', testGeneratorNextEncoding, foobarString, 'utf8', true, false, 'String');80-test('Next generator argument is string with default encoding, with string writes, objectMode both', testGeneratorNextEncoding, foobarString, 'utf8', true, true, 'String');81-test('Next generator argument is string with default encoding, with Uint8Array writes', testGeneratorNextEncoding, foobarUint8Array, 'utf8', false, false, 'String');82-test('Next generator argument is Uint8Array with default encoding, with Uint8Array writes, objectMode first', testGeneratorNextEncoding, foobarUint8Array, 'utf8', true, false, 'Uint8Array');83-test('Next generator argument is string with default encoding, with Uint8Array writes, objectMode both', testGeneratorNextEncoding, foobarUint8Array, 'utf8', true, true, 'Uint8Array');84-test('Next generator argument is Uint8Array with encoding "buffer", with string writes', testGeneratorNextEncoding, foobarString, 'buffer', false, false, 'Uint8Array');85-test('Next generator argument is string with encoding "buffer", with string writes, objectMode first', testGeneratorNextEncoding, foobarString, 'buffer', true, false, 'String');86-test('Next generator argument is string with encoding "buffer", with string writes, objectMode both', testGeneratorNextEncoding, foobarString, 'buffer', true, true, 'String');87-test('Next generator argument is Uint8Array with encoding "buffer", with Uint8Array writes', testGeneratorNextEncoding, foobarUint8Array, 'buffer', false, false, 'Uint8Array');88-test('Next generator argument is Uint8Array with encoding "buffer", with Uint8Array writes, objectMode first', testGeneratorNextEncoding, foobarUint8Array, 'buffer', true, false, 'Uint8Array');89-test('Next generator argument is Uint8Array with encoding "buffer", with Uint8Array writes, objectMode both', testGeneratorNextEncoding, foobarUint8Array, 'buffer', true, true, 'Uint8Array');90-test('Next generator argument is Uint8Array with encoding "hex", with string writes', testGeneratorNextEncoding, foobarString, 'hex', false, false, 'Uint8Array');91-test('Next generator argument is Uint8Array with encoding "hex", with Uint8Array writes', testGeneratorNextEncoding, foobarUint8Array, 'hex', false, false, 'Uint8Array');92-test('Next generator argument is object with default encoding, with object writes, objectMode first', testGeneratorNextEncoding, foobarObject, 'utf8', true, false, 'Object');93-test('Next generator argument is object with default encoding, with object writes, objectMode both', testGeneratorNextEncoding, foobarObject, 'utf8', true, true, 'Object');98+test('Next generator argument is string with default encoding, with string writes', testGeneratorNextEncoding, foobarString, 'utf8', false, false, 'String', execa);99+test('Next generator argument is string with default encoding, with string writes, objectMode first', testGeneratorNextEncoding, foobarString, 'utf8', true, false, 'String', execa);100+test('Next generator argument is string with default encoding, with string writes, objectMode both', testGeneratorNextEncoding, foobarString, 'utf8', true, true, 'String', execa);101+test('Next generator argument is string with default encoding, with Uint8Array writes', testGeneratorNextEncoding, foobarUint8Array, 'utf8', false, false, 'String', execa);102+test('Next generator argument is Uint8Array with default encoding, with Uint8Array writes, objectMode first', testGeneratorNextEncoding, foobarUint8Array, 'utf8', true, false, 'Uint8Array', execa);103+test('Next generator argument is string with default encoding, with Uint8Array writes, objectMode both', testGeneratorNextEncoding, foobarUint8Array, 'utf8', true, true, 'Uint8Array', execa);104+test('Next generator argument is Uint8Array with encoding "buffer", with string writes', testGeneratorNextEncoding, foobarString, 'buffer', false, false, 'Uint8Array', execa);105+test('Next generator argument is string with encoding "buffer", with string writes, objectMode first', testGeneratorNextEncoding, foobarString, 'buffer', true, false, 'String', execa);106+test('Next generator argument is string with encoding "buffer", with string writes, objectMode both', testGeneratorNextEncoding, foobarString, 'buffer', true, true, 'String', execa);107+test('Next generator argument is Uint8Array with encoding "buffer", with Uint8Array writes', testGeneratorNextEncoding, foobarUint8Array, 'buffer', false, false, 'Uint8Array', execa);108+test('Next generator argument is Uint8Array with encoding "buffer", with Uint8Array writes, objectMode first', testGeneratorNextEncoding, foobarUint8Array, 'buffer', true, false, 'Uint8Array', execa);109+test('Next generator argument is Uint8Array with encoding "buffer", with Uint8Array writes, objectMode both', testGeneratorNextEncoding, foobarUint8Array, 'buffer', true, true, 'Uint8Array', execa);110+test('Next generator argument is Uint8Array with encoding "hex", with string writes', testGeneratorNextEncoding, foobarString, 'hex', false, false, 'Uint8Array', execa);111+test('Next generator argument is Uint8Array with encoding "hex", with Uint8Array writes', testGeneratorNextEncoding, foobarUint8Array, 'hex', false, false, 'Uint8Array', execa);112+test('Next generator argument is object with default encoding, with object writes, objectMode first', testGeneratorNextEncoding, foobarObject, 'utf8', true, false, 'Object', execa);113+test('Next generator argument is object with default encoding, with object writes, objectMode both', testGeneratorNextEncoding, foobarObject, 'utf8', true, true, 'Object', execa);114+test('Next generator argument is string with default encoding, with string writes, sync', testGeneratorNextEncoding, foobarString, 'utf8', false, false, 'String', execaSync);115+test('Next generator argument is string with default encoding, with string writes, objectMode first, sync', testGeneratorNextEncoding, foobarString, 'utf8', true, false, 'String', execaSync);116+test('Next generator argument is string with default encoding, with string writes, objectMode both, sync', testGeneratorNextEncoding, foobarString, 'utf8', true, true, 'String', execaSync);117+test('Next generator argument is string with default encoding, with Uint8Array writes, sync', testGeneratorNextEncoding, foobarUint8Array, 'utf8', false, false, 'String', execaSync);118+test('Next generator argument is Uint8Array with default encoding, with Uint8Array writes, objectMode first, sync', testGeneratorNextEncoding, foobarUint8Array, 'utf8', true, false, 'Uint8Array', execaSync);119+test('Next generator argument is string with default encoding, with Uint8Array writes, objectMode both, sync', testGeneratorNextEncoding, foobarUint8Array, 'utf8', true, true, 'Uint8Array', execaSync);120+test('Next generator argument is Uint8Array with encoding "buffer", with string writes, sync', testGeneratorNextEncoding, foobarString, 'buffer', false, false, 'Uint8Array', execaSync);121+test('Next generator argument is string with encoding "buffer", with string writes, objectMode first, sync', testGeneratorNextEncoding, foobarString, 'buffer', true, false, 'String', execaSync);122+test('Next generator argument is string with encoding "buffer", with string writes, objectMode both, sync', testGeneratorNextEncoding, foobarString, 'buffer', true, true, 'String', execaSync);123+test('Next generator argument is Uint8Array with encoding "buffer", with Uint8Array writes, sync', testGeneratorNextEncoding, foobarUint8Array, 'buffer', false, false, 'Uint8Array', execaSync);124+test('Next generator argument is Uint8Array with encoding "buffer", with Uint8Array writes, objectMode first, sync', testGeneratorNextEncoding, foobarUint8Array, 'buffer', true, false, 'Uint8Array', execaSync);125+test('Next generator argument is Uint8Array with encoding "buffer", with Uint8Array writes, objectMode both, sync', testGeneratorNextEncoding, foobarUint8Array, 'buffer', true, true, 'Uint8Array', execaSync);126+test('Next generator argument is Uint8Array with encoding "hex", with string writes, sync', testGeneratorNextEncoding, foobarString, 'hex', false, false, 'Uint8Array', execaSync);127+test('Next generator argument is Uint8Array with encoding "hex", with Uint8Array writes, sync', testGeneratorNextEncoding, foobarUint8Array, 'hex', false, false, 'Uint8Array', execaSync);128+test('Next generator argument is object with default encoding, with object writes, objectMode first, sync', testGeneratorNextEncoding, foobarObject, 'utf8', true, false, 'Object', execaSync);129+test('Next generator argument is object with default encoding, with object writes, objectMode both, sync', testGeneratorNextEncoding, foobarObject, 'utf8', true, true, 'Object', execaSync);130 95-const testFirstOutputGeneratorArgument = async (t, fdNumber) => {96- const {stdio} = await execa('noop-fd.js', [`${fdNumber}`], getStdio(fdNumber, getTypeofGenerator(true)));131+const testFirstOutputGeneratorArgument = async (t, fdNumber, execaMethod) => {132+ const {stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`], getStdio(fdNumber, getTypeofGenerator(true)));133 t.deepEqual(stdio[fdNumber], ['[object String]']);134 };135 100-test('The first generator with result.stdout does not receive an object argument even in objectMode', testFirstOutputGeneratorArgument, 1);101-test('The first generator with result.stderr does not receive an object argument even in objectMode', testFirstOutputGeneratorArgument, 2);102-test('The first generator with result.stdio[*] does not receive an object argument even in objectMode', testFirstOutputGeneratorArgument, 3);136+test('The first generator with result.stdout does not receive an object argument even in objectMode', testFirstOutputGeneratorArgument, 1, execa);137+test('The first generator with result.stderr does not receive an object argument even in objectMode', testFirstOutputGeneratorArgument, 2, execa);138+test('The first generator with result.stdio[*] does not receive an object argument even in objectMode', testFirstOutputGeneratorArgument, 3, execa);139+test('The first generator with result.stdout does not receive an object argument even in objectMode, sync', testFirstOutputGeneratorArgument, 1, execaSync);140+test('The first generator with result.stderr does not receive an object argument even in objectMode, sync', testFirstOutputGeneratorArgument, 2, execaSync);141+test('The first generator with result.stdio[*] does not receive an object argument even in objectMode, sync', testFirstOutputGeneratorArgument, 3, execaSync);142 143 // eslint-disable-next-line max-params105-const testGeneratorReturnType = async (t, input, encoding, reject, objectMode, final) => {144+const testGeneratorReturnType = async (t, input, encoding, reject, objectMode, final, execaMethod) => {145 const fixtureName = reject ? 'noop-fd.js' : 'noop-fail.js';107- const {stdout} = await execa(fixtureName, ['1', foobarString], {146+ const {stdout} = await execaMethod(fixtureName, ['1', foobarString], {147 stdout: convertTransformToFinal(getOutputGenerator(input)(objectMode, true), final),148 encoding,149 reject,150 });1 unmodified line152 const output = Buffer.from(typeofChunk, encoding === 'buffer' || objectMode ? undefined : encoding).toString();153 t.is(output, foobarString);154 };155 117-test('Generator can return string with default encoding', testGeneratorReturnType, foobarString, 'utf8', true, false, false);118-test('Generator can return Uint8Array with default encoding', testGeneratorReturnType, foobarUint8Array, 'utf8', true, false, false);119-test('Generator can return string with encoding "buffer"', testGeneratorReturnType, foobarString, 'buffer', true, false, false);120-test('Generator can return Uint8Array with encoding "buffer"', testGeneratorReturnType, foobarUint8Array, 'buffer', true, false, false);121-test('Generator can return string with encoding "hex"', testGeneratorReturnType, foobarString, 'hex', true, false, false);122-test('Generator can return Uint8Array with encoding "hex"', testGeneratorReturnType, foobarUint8Array, 'hex', true, false, false);123-test('Generator can return string with default encoding, failure', testGeneratorReturnType, foobarString, 'utf8', false, false, false);124-test('Generator can return Uint8Array with default encoding, failure', testGeneratorReturnType, foobarUint8Array, 'utf8', false, false, false);125-test('Generator can return string with encoding "buffer", failure', testGeneratorReturnType, foobarString, 'buffer', false, false, false);126-test('Generator can return Uint8Array with encoding "buffer", failure', testGeneratorReturnType, foobarUint8Array, 'buffer', false, false, false);127-test('Generator can return string with encoding "hex", failure', testGeneratorReturnType, foobarString, 'hex', false, false, false);128-test('Generator can return Uint8Array with encoding "hex", failure', testGeneratorReturnType, foobarUint8Array, 'hex', false, false, false);129-test('Generator can return string with default encoding, objectMode', testGeneratorReturnType, foobarString, 'utf8', true, true, false);130-test('Generator can return Uint8Array with default encoding, objectMode', testGeneratorReturnType, foobarUint8Array, 'utf8', true, true, false);131-test('Generator can return string with encoding "buffer", objectMode', testGeneratorReturnType, foobarString, 'buffer', true, true, false);132-test('Generator can return Uint8Array with encoding "buffer", objectMode', testGeneratorReturnType, foobarUint8Array, 'buffer', true, true, false);133-test('Generator can return string with encoding "hex", objectMode', testGeneratorReturnType, foobarString, 'hex', true, true, false);134-test('Generator can return Uint8Array with encoding "hex", objectMode', testGeneratorReturnType, foobarUint8Array, 'hex', true, true, false);135-test('Generator can return string with default encoding, objectMode, failure', testGeneratorReturnType, foobarString, 'utf8', false, true, false);136-test('Generator can return Uint8Array with default encoding, objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'utf8', false, true, false);137-test('Generator can return string with encoding "buffer", objectMode, failure', testGeneratorReturnType, foobarString, 'buffer', false, true, false);138-test('Generator can return Uint8Array with encoding "buffer", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'buffer', false, true, false);139-test('Generator can return string with encoding "hex", objectMode, failure', testGeneratorReturnType, foobarString, 'hex', false, true, false);140-test('Generator can return Uint8Array with encoding "hex", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'hex', false, true, false);141-test('Generator can return final string with default encoding', testGeneratorReturnType, foobarString, 'utf8', true, false, true);142-test('Generator can return final Uint8Array with default encoding', testGeneratorReturnType, foobarUint8Array, 'utf8', true, false, true);143-test('Generator can return final string with encoding "buffer"', testGeneratorReturnType, foobarString, 'buffer', true, false, true);144-test('Generator can return final Uint8Array with encoding "buffer"', testGeneratorReturnType, foobarUint8Array, 'buffer', true, false, true);145-test('Generator can return final string with encoding "hex"', testGeneratorReturnType, foobarString, 'hex', true, false, true);146-test('Generator can return final Uint8Array with encoding "hex"', testGeneratorReturnType, foobarUint8Array, 'hex', true, false, true);147-test('Generator can return final string with default encoding, failure', testGeneratorReturnType, foobarString, 'utf8', false, false, true);148-test('Generator can return final Uint8Array with default encoding, failure', testGeneratorReturnType, foobarUint8Array, 'utf8', false, false, true);149-test('Generator can return final string with encoding "buffer", failure', testGeneratorReturnType, foobarString, 'buffer', false, false, true);150-test('Generator can return final Uint8Array with encoding "buffer", failure', testGeneratorReturnType, foobarUint8Array, 'buffer', false, false, true);151-test('Generator can return final string with encoding "hex", failure', testGeneratorReturnType, foobarString, 'hex', false, false, true);152-test('Generator can return final Uint8Array with encoding "hex", failure', testGeneratorReturnType, foobarUint8Array, 'hex', false, false, true);153-test('Generator can return final string with default encoding, objectMode', testGeneratorReturnType, foobarString, 'utf8', true, true, true);154-test('Generator can return final Uint8Array with default encoding, objectMode', testGeneratorReturnType, foobarUint8Array, 'utf8', true, true, true);155-test('Generator can return final string with encoding "buffer", objectMode', testGeneratorReturnType, foobarString, 'buffer', true, true, true);156-test('Generator can return final Uint8Array with encoding "buffer", objectMode', testGeneratorReturnType, foobarUint8Array, 'buffer', true, true, true);157-test('Generator can return final string with encoding "hex", objectMode', testGeneratorReturnType, foobarString, 'hex', true, true, true);158-test('Generator can return final Uint8Array with encoding "hex", objectMode', testGeneratorReturnType, foobarUint8Array, 'hex', true, true, true);159-test('Generator can return final string with default encoding, objectMode, failure', testGeneratorReturnType, foobarString, 'utf8', false, true, true);160-test('Generator can return final Uint8Array with default encoding, objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'utf8', false, true, true);161-test('Generator can return final string with encoding "buffer", objectMode, failure', testGeneratorReturnType, foobarString, 'buffer', false, true, true);162-test('Generator can return final Uint8Array with encoding "buffer", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'buffer', false, true, true);163-test('Generator can return final string with encoding "hex", objectMode, failure', testGeneratorReturnType, foobarString, 'hex', false, true, true);164-test('Generator can return final Uint8Array with encoding "hex", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'hex', false, true, true);156+test('Generator can return string with default encoding', testGeneratorReturnType, foobarString, 'utf8', true, false, false, execa);157+test('Generator can return Uint8Array with default encoding', testGeneratorReturnType, foobarUint8Array, 'utf8', true, false, false, execa);158+test('Generator can return string with encoding "buffer"', testGeneratorReturnType, foobarString, 'buffer', true, false, false, execa);159+test('Generator can return Uint8Array with encoding "buffer"', testGeneratorReturnType, foobarUint8Array, 'buffer', true, false, false, execa);160+test('Generator can return string with encoding "hex"', testGeneratorReturnType, foobarString, 'hex', true, false, false, execa);161+test('Generator can return Uint8Array with encoding "hex"', testGeneratorReturnType, foobarUint8Array, 'hex', true, false, false, execa);162+test('Generator can return string with default encoding, failure', testGeneratorReturnType, foobarString, 'utf8', false, false, false, execa);163+test('Generator can return Uint8Array with default encoding, failure', testGeneratorReturnType, foobarUint8Array, 'utf8', false, false, false, execa);164+test('Generator can return string with encoding "buffer", failure', testGeneratorReturnType, foobarString, 'buffer', false, false, false, execa);165+test('Generator can return Uint8Array with encoding "buffer", failure', testGeneratorReturnType, foobarUint8Array, 'buffer', false, false, false, execa);166+test('Generator can return string with encoding "hex", failure', testGeneratorReturnType, foobarString, 'hex', false, false, false, execa);167+test('Generator can return Uint8Array with encoding "hex", failure', testGeneratorReturnType, foobarUint8Array, 'hex', false, false, false, execa);168+test('Generator can return string with default encoding, objectMode', testGeneratorReturnType, foobarString, 'utf8', true, true, false, execa);169+test('Generator can return Uint8Array with default encoding, objectMode', testGeneratorReturnType, foobarUint8Array, 'utf8', true, true, false, execa);170+test('Generator can return string with encoding "buffer", objectMode', testGeneratorReturnType, foobarString, 'buffer', true, true, false, execa);171+test('Generator can return Uint8Array with encoding "buffer", objectMode', testGeneratorReturnType, foobarUint8Array, 'buffer', true, true, false, execa);172+test('Generator can return string with encoding "hex", objectMode', testGeneratorReturnType, foobarString, 'hex', true, true, false, execa);173+test('Generator can return Uint8Array with encoding "hex", objectMode', testGeneratorReturnType, foobarUint8Array, 'hex', true, true, false, execa);174+test('Generator can return string with default encoding, objectMode, failure', testGeneratorReturnType, foobarString, 'utf8', false, true, false, execa);175+test('Generator can return Uint8Array with default encoding, objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'utf8', false, true, false, execa);176+test('Generator can return string with encoding "buffer", objectMode, failure', testGeneratorReturnType, foobarString, 'buffer', false, true, false, execa);177+test('Generator can return Uint8Array with encoding "buffer", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'buffer', false, true, false, execa);178+test('Generator can return string with encoding "hex", objectMode, failure', testGeneratorReturnType, foobarString, 'hex', false, true, false, execa);179+test('Generator can return Uint8Array with encoding "hex", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'hex', false, true, false, execa);180+test('Generator can return final string with default encoding', testGeneratorReturnType, foobarString, 'utf8', true, false, true, execa);181+test('Generator can return final Uint8Array with default encoding', testGeneratorReturnType, foobarUint8Array, 'utf8', true, false, true, execa);182+test('Generator can return final string with encoding "buffer"', testGeneratorReturnType, foobarString, 'buffer', true, false, true, execa);183+test('Generator can return final Uint8Array with encoding "buffer"', testGeneratorReturnType, foobarUint8Array, 'buffer', true, false, true, execa);184+test('Generator can return final string with encoding "hex"', testGeneratorReturnType, foobarString, 'hex', true, false, true, execa);185+test('Generator can return final Uint8Array with encoding "hex"', testGeneratorReturnType, foobarUint8Array, 'hex', true, false, true, execa);186+test('Generator can return final string with default encoding, failure', testGeneratorReturnType, foobarString, 'utf8', false, false, true, execa);187+test('Generator can return final Uint8Array with default encoding, failure', testGeneratorReturnType, foobarUint8Array, 'utf8', false, false, true, execa);188+test('Generator can return final string with encoding "buffer", failure', testGeneratorReturnType, foobarString, 'buffer', false, false, true, execa);189+test('Generator can return final Uint8Array with encoding "buffer", failure', testGeneratorReturnType, foobarUint8Array, 'buffer', false, false, true, execa);190+test('Generator can return final string with encoding "hex", failure', testGeneratorReturnType, foobarString, 'hex', false, false, true, execa);191+test('Generator can return final Uint8Array with encoding "hex", failure', testGeneratorReturnType, foobarUint8Array, 'hex', false, false, true, execa);192+test('Generator can return final string with default encoding, objectMode', testGeneratorReturnType, foobarString, 'utf8', true, true, true, execa);193+test('Generator can return final Uint8Array with default encoding, objectMode', testGeneratorReturnType, foobarUint8Array, 'utf8', true, true, true, execa);194+test('Generator can return final string with encoding "buffer", objectMode', testGeneratorReturnType, foobarString, 'buffer', true, true, true, execa);195+test('Generator can return final Uint8Array with encoding "buffer", objectMode', testGeneratorReturnType, foobarUint8Array, 'buffer', true, true, true, execa);196+test('Generator can return final string with encoding "hex", objectMode', testGeneratorReturnType, foobarString, 'hex', true, true, true, execa);197+test('Generator can return final Uint8Array with encoding "hex", objectMode', testGeneratorReturnType, foobarUint8Array, 'hex', true, true, true, execa);198+test('Generator can return final string with default encoding, objectMode, failure', testGeneratorReturnType, foobarString, 'utf8', false, true, true, execa);199+test('Generator can return final Uint8Array with default encoding, objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'utf8', false, true, true, execa);200+test('Generator can return final string with encoding "buffer", objectMode, failure', testGeneratorReturnType, foobarString, 'buffer', false, true, true, execa);201+test('Generator can return final Uint8Array with encoding "buffer", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'buffer', false, true, true, execa);202+test('Generator can return final string with encoding "hex", objectMode, failure', testGeneratorReturnType, foobarString, 'hex', false, true, true, execa);203+test('Generator can return final Uint8Array with encoding "hex", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'hex', false, true, true, execa);204+test('Generator can return string with default encoding, sync', testGeneratorReturnType, foobarString, 'utf8', true, false, false, execaSync);205+test('Generator can return Uint8Array with default encoding, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', true, false, false, execaSync);206+test('Generator can return string with encoding "buffer", sync', testGeneratorReturnType, foobarString, 'buffer', true, false, false, execaSync);207+test('Generator can return Uint8Array with encoding "buffer", sync', testGeneratorReturnType, foobarUint8Array, 'buffer', true, false, false, execaSync);208+test('Generator can return string with encoding "hex", sync', testGeneratorReturnType, foobarString, 'hex', true, false, false, execaSync);209+test('Generator can return Uint8Array with encoding "hex", sync', testGeneratorReturnType, foobarUint8Array, 'hex', true, false, false, execaSync);210+test('Generator can return string with default encoding, failure, sync', testGeneratorReturnType, foobarString, 'utf8', false, false, false, execaSync);211+test('Generator can return Uint8Array with default encoding, failure, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', false, false, false, execaSync);212+test('Generator can return string with encoding "buffer", failure, sync', testGeneratorReturnType, foobarString, 'buffer', false, false, false, execaSync);213+test('Generator can return Uint8Array with encoding "buffer", failure, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', false, false, false, execaSync);214+test('Generator can return string with encoding "hex", failure, sync', testGeneratorReturnType, foobarString, 'hex', false, false, false, execaSync);215+test('Generator can return Uint8Array with encoding "hex", failure, sync', testGeneratorReturnType, foobarUint8Array, 'hex', false, false, false, execaSync);216+test('Generator can return string with default encoding, objectMode, sync', testGeneratorReturnType, foobarString, 'utf8', true, true, false, execaSync);217+test('Generator can return Uint8Array with default encoding, objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', true, true, false, execaSync);218+test('Generator can return string with encoding "buffer", objectMode, sync', testGeneratorReturnType, foobarString, 'buffer', true, true, false, execaSync);219+test('Generator can return Uint8Array with encoding "buffer", objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', true, true, false, execaSync);220+test('Generator can return string with encoding "hex", objectMode, sync', testGeneratorReturnType, foobarString, 'hex', true, true, false, execaSync);221+test('Generator can return Uint8Array with encoding "hex", objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'hex', true, true, false, execaSync);222+test('Generator can return string with default encoding, objectMode, failure, sync', testGeneratorReturnType, foobarString, 'utf8', false, true, false, execaSync);223+test('Generator can return Uint8Array with default encoding, objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', false, true, false, execaSync);224+test('Generator can return string with encoding "buffer", objectMode, failure, sync', testGeneratorReturnType, foobarString, 'buffer', false, true, false, execaSync);225+test('Generator can return Uint8Array with encoding "buffer", objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', false, true, false, execaSync);226+test('Generator can return string with encoding "hex", objectMode, failure, sync', testGeneratorReturnType, foobarString, 'hex', false, true, false, execaSync);227+test('Generator can return Uint8Array with encoding "hex", objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'hex', false, true, false, execaSync);228+test('Generator can return final string with default encoding, sync', testGeneratorReturnType, foobarString, 'utf8', true, false, true, execaSync);229+test('Generator can return final Uint8Array with default encoding, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', true, false, true, execaSync);230+test('Generator can return final string with encoding "buffer", sync', testGeneratorReturnType, foobarString, 'buffer', true, false, true, execaSync);231+test('Generator can return final Uint8Array with encoding "buffer", sync', testGeneratorReturnType, foobarUint8Array, 'buffer', true, false, true, execaSync);232+test('Generator can return final string with encoding "hex", sync', testGeneratorReturnType, foobarString, 'hex', true, false, true, execaSync);233+test('Generator can return final Uint8Array with encoding "hex", sync', testGeneratorReturnType, foobarUint8Array, 'hex', true, false, true, execaSync);234+test('Generator can return final string with default encoding, failure, sync', testGeneratorReturnType, foobarString, 'utf8', false, false, true, execaSync);235+test('Generator can return final Uint8Array with default encoding, failure, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', false, false, true, execaSync);236+test('Generator can return final string with encoding "buffer", failure, sync', testGeneratorReturnType, foobarString, 'buffer', false, false, true, execaSync);237+test('Generator can return final Uint8Array with encoding "buffer", failure, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', false, false, true, execaSync);238+test('Generator can return final string with encoding "hex", failure, sync', testGeneratorReturnType, foobarString, 'hex', false, false, true, execaSync);239+test('Generator can return final Uint8Array with encoding "hex", failure, sync', testGeneratorReturnType, foobarUint8Array, 'hex', false, false, true, execaSync);240+test('Generator can return final string with default encoding, objectMode, sync', testGeneratorReturnType, foobarString, 'utf8', true, true, true, execaSync);241+test('Generator can return final Uint8Array with default encoding, objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', true, true, true, execaSync);242+test('Generator can return final string with encoding "buffer", objectMode, sync', testGeneratorReturnType, foobarString, 'buffer', true, true, true, execaSync);243+test('Generator can return final Uint8Array with encoding "buffer", objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', true, true, true, execaSync);244+test('Generator can return final string with encoding "hex", objectMode, sync', testGeneratorReturnType, foobarString, 'hex', true, true, true, execaSync);245+test('Generator can return final Uint8Array with encoding "hex", objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'hex', true, true, true, execaSync);246+test('Generator can return final string with default encoding, objectMode, failure, sync', testGeneratorReturnType, foobarString, 'utf8', false, true, true, execaSync);247+test('Generator can return final Uint8Array with default encoding, objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', false, true, true, execaSync);248+test('Generator can return final string with encoding "buffer", objectMode, failure, sync', testGeneratorReturnType, foobarString, 'buffer', false, true, true, execaSync);249+test('Generator can return final Uint8Array with encoding "buffer", objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', false, true, true, execaSync);250+test('Generator can return final string with encoding "hex", objectMode, failure, sync', testGeneratorReturnType, foobarString, 'hex', false, true, true, execaSync);251+test('Generator can return final Uint8Array with encoding "hex", objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'hex', false, true, true, execaSync);252 166-const testMultibyte = async (t, objectMode) => {167- const subprocess = execa('stdin.js', {stdin: noopGenerator(objectMode, true)});168- subprocess.stdin.write(multibyteUint8Array.slice(0, breakingLength));169- await scheduler.yield();170- subprocess.stdin.end(multibyteUint8Array.slice(breakingLength));171- const {stdout} = await subprocess;253+const testMultibyte = async (t, objectMode, execaMethod) => {254+ const {stdout} = await execaMethod('stdin.js', {255+ stdin: [256+ [multibyteUint8Array.slice(0, breakingLength), multibyteUint8Array.slice(breakingLength)],257+ noopGenerator(objectMode, true),258+ ],259+ });260 t.is(stdout, multibyteString);261 };262 175-test('Generator handles multibyte characters with Uint8Array', testMultibyte, false);176-test('Generator handles multibyte characters with Uint8Array, objectMode', testMultibyte, true);263+test('Generator handles multibyte characters with Uint8Array', testMultibyte, false, execa);264+test('Generator handles multibyte characters with Uint8Array, objectMode', testMultibyte, true, execa);265+test('Generator handles multibyte characters with Uint8Array, sync', testMultibyte, false, execaSync);266+test('Generator handles multibyte characters with Uint8Array, objectMode, sync', testMultibyte, true, execaSync);267 178-const testMultibytePartial = async (t, objectMode) => {179- const {stdout} = await execa('stdin.js', {268+const testMultibytePartial = async (t, objectMode, execaMethod) => {269+ const {stdout} = await execaMethod('stdin.js', {270 stdin: [271 [multibyteUint8Array.slice(0, breakingLength)],272 noopGenerator(objectMode, true),273 ],274 });275 t.is(stdout, `${multibyteChar}${brokenSymbol}`);276 };277 188-test('Generator handles partial multibyte characters with Uint8Array', testMultibytePartial, false);189-test('Generator handles partial multibyte characters with Uint8Array, objectMode', testMultibytePartial, true);278+test('Generator handles partial multibyte characters with Uint8Array', testMultibytePartial, false, execa);279+test('Generator handles partial multibyte characters with Uint8Array, objectMode', testMultibytePartial, true, execa);280+test('Generator handles partial multibyte characters with Uint8Array, sync', testMultibytePartial, false, execaSync);281+test('Generator handles partial multibyte characters with Uint8Array, objectMode, sync', testMultibytePartial, true, execaSync);282+283+const testMultibytePartialOutput = async (t, execaMethod) => {284+ const {stdout} = await execaMethod('noop.js', {285+ stdout: getOutputsGenerator([286+ multibyteUint8Array.slice(0, breakingLength),287+ multibyteUint8Array.slice(breakingLength),288+ ])(false, true),289+ });290+ t.is(stdout, multibyteString);291+};292+293+test('Generator handles output multibyte characters with Uint8Array', testMultibytePartialOutput, execa);294+test('Generator handles output multibyte characters with Uint8Array, sync', testMultibytePartialOutput, execaSync);modified:test/stdio/file-path.js+122 added-1 removed
1 unmodified line2 import {relative, dirname, basename} from 'node:path';3 import process from 'node:process';4 import {pathToFileURL} from 'node:url';5 import test from 'ava';6+import {pathExists} from 'path-exists';7 import tempfile from 'tempfile';8 import {execa, execaSync} from '../../index.js';9 import {setFixtureDir} from '../helpers/fixtures-dir.js';10 import {identity, getStdio} from '../helpers/stdio.js';11 import {runExeca, runExecaSync, runScript, runScriptSync} from '../helpers/run.js';11-import {foobarString, foobarUint8Array} from '../helpers/input.js';12+import {foobarString, foobarUint8Array, foobarUppercase} from '../helpers/input.js';13+import {outputObjectGenerator, uppercaseGenerator, serializeGenerator, throwingGenerator} from '../helpers/generator.js';14 15 setFixtureDir();16 17 const nonFileUrl = new URL('https://example.com');216 unmodified lines234 };235 236 test('Passing an input file path when subprocess exits does not make promise hang', testInputFileHanging, getAbsolutePath);237 test('Passing an input file URL when subprocess exits does not make promise hang', testInputFileHanging, pathToFileURL);238+239+const testInputFileTransform = async (t, fdNumber, mapFile, execaMethod) => {240+ const filePath = tempfile();241+ await writeFile(filePath, foobarString);242+ const {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [243+ new Uint8Array(),244+ mapFile(filePath),245+ uppercaseGenerator(),246+ ]));247+ t.is(stdout, foobarUppercase);248+ await rm(filePath);249+};250+251+test('stdin can use generators together with input file paths', testInputFileTransform, 0, getAbsolutePath, execa);252+test('stdin can use generators together with input file URLs', testInputFileTransform, 0, pathToFileURL, execa);253+test('stdio[*] can use generators together with input file paths', testInputFileTransform, 3, getAbsolutePath, execa);254+test('stdio[*] can use generators together with input file URLs', testInputFileTransform, 3, pathToFileURL, execa);255+test('stdin can use generators together with input file paths, sync', testInputFileTransform, 0, getAbsolutePath, execaSync);256+test('stdin can use generators together with input file URLs, sync', testInputFileTransform, 0, pathToFileURL, execaSync);257+258+const testInputFileObject = async (t, fdNumber, mapFile, execaMethod) => {259+ const filePath = tempfile();260+ await writeFile(filePath, foobarString);261+ t.throws(() => {262+ execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [263+ new Uint8Array(),264+ mapFile(filePath),265+ serializeGenerator(true),266+ ]));267+ }, {message: /cannot use both files and transforms in objectMode/});268+ await rm(filePath);269+};270+271+test('stdin cannot use objectMode together with input file paths', testInputFileObject, 0, getAbsolutePath, execa);272+test('stdin cannot use objectMode together with input file URLs', testInputFileObject, 0, pathToFileURL, execa);273+test('stdio[*] cannot use objectMode together with input file paths', testInputFileObject, 3, getAbsolutePath, execa);274+test('stdio[*] cannot use objectMode together with input file URLs', testInputFileObject, 3, pathToFileURL, execa);275+test('stdin cannot use objectMode together with input file paths, sync', testInputFileObject, 0, getAbsolutePath, execaSync);276+test('stdin cannot use objectMode together with input file URLs, sync', testInputFileObject, 0, pathToFileURL, execaSync);277+278+const testOutputFileTransform = async (t, fdNumber, mapFile, execaMethod) => {279+ const filePath = tempfile();280+ await execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, [281+ uppercaseGenerator(),282+ mapFile(filePath),283+ ]));284+ t.is(await readFile(filePath, 'utf8'), `${foobarUppercase}\n`);285+ await rm(filePath);286+};287+288+test('stdout can use generators together with output file paths', testOutputFileTransform, 1, getAbsolutePath, execa);289+test('stdout can use generators together with output file URLs', testOutputFileTransform, 1, pathToFileURL, execa);290+test('stderr can use generators together with output file paths', testOutputFileTransform, 2, getAbsolutePath, execa);291+test('stderr can use generators together with output file URLs', testOutputFileTransform, 2, pathToFileURL, execa);292+test('stdio[*] can use generators together with output file paths', testOutputFileTransform, 3, getAbsolutePath, execa);293+test('stdio[*] can use generators together with output file URLs', testOutputFileTransform, 3, pathToFileURL, execa);294+test('stdout can use generators together with output file paths, sync', testOutputFileTransform, 1, getAbsolutePath, execaSync);295+test('stdout can use generators together with output file URLs, sync', testOutputFileTransform, 1, pathToFileURL, execaSync);296+test('stderr can use generators together with output file paths, sync', testOutputFileTransform, 2, getAbsolutePath, execaSync);297+test('stderr can use generators together with output file URLs, sync', testOutputFileTransform, 2, pathToFileURL, execaSync);298+test('stdio[*] can use generators together with output file paths, sync', testOutputFileTransform, 3, getAbsolutePath, execaSync);299+test('stdio[*] can use generators together with output file URLs, sync', testOutputFileTransform, 3, pathToFileURL, execaSync);300+301+const testOutputFileObject = async (t, fdNumber, mapFile, execaMethod) => {302+ const filePath = tempfile();303+ t.throws(() => {304+ execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, [305+ outputObjectGenerator(),306+ mapFile(filePath),307+ ]));308+ }, {message: /cannot use both files and transforms in objectMode/});309+ t.false(await pathExists(filePath));310+};311+312+test('stdout cannot use objectMode together with output file paths', testOutputFileObject, 1, getAbsolutePath, execa);313+test('stdout cannot use objectMode together with output file URLs', testOutputFileObject, 1, pathToFileURL, execa);314+test('stderr cannot use objectMode together with output file paths', testOutputFileObject, 2, getAbsolutePath, execa);315+test('stderr cannot use objectMode together with output file URLs', testOutputFileObject, 2, pathToFileURL, execa);316+test('stdio[*] cannot use objectMode together with output file paths', testOutputFileObject, 3, getAbsolutePath, execa);317+test('stdio[*] cannot use objectMode together with output file URLs', testOutputFileObject, 3, pathToFileURL, execa);318+test('stdout cannot use objectMode together with output file paths, sync', testOutputFileObject, 1, getAbsolutePath, execaSync);319+test('stdout cannot use objectMode together with output file URLs, sync', testOutputFileObject, 1, pathToFileURL, execaSync);320+test('stderr cannot use objectMode together with output file paths, sync', testOutputFileObject, 2, getAbsolutePath, execaSync);321+test('stderr cannot use objectMode together with output file URLs, sync', testOutputFileObject, 2, pathToFileURL, execaSync);322+test('stdio[*] cannot use objectMode together with output file paths, sync', testOutputFileObject, 3, getAbsolutePath, execaSync);323+test('stdio[*] cannot use objectMode together with output file URLs, sync', testOutputFileObject, 3, pathToFileURL, execaSync);324+325+test('Generator error stops writing to output file', async t => {326+ const filePath = tempfile();327+ const cause = new Error(foobarString);328+ const error = await t.throwsAsync(execa('noop.js', {329+ stdout: [throwingGenerator(cause)(), getAbsolutePath(filePath)],330+ }));331+ t.is(error.cause, cause);332+ t.is(await readFile(filePath, 'utf8'), '');333+});334+335+test('Generator error does not create output file, sync', async t => {336+ const filePath = tempfile();337+ const cause = new Error(foobarString);338+ const error = t.throws(() => {339+ execaSync('noop.js', {340+ stdout: [throwingGenerator(cause)(), getAbsolutePath(filePath)],341+ });342+ });343+ t.is(error.cause, cause);344+ t.false(await pathExists(filePath));345+});346+347+test('Output file error still returns transformed output, sync', async t => {348+ const filePath = tempfile();349+ const {stdout} = t.throws(() => {350+ execaSync('noop-fd.js', ['1', foobarString], {351+ stdout: [uppercaseGenerator(), getAbsolutePath('./unknown/file')],352+ });353+ }, {code: 'ENOENT'});354+ t.false(await pathExists(filePath));355+ t.is(stdout, foobarUppercase);356+});modified:test/stdio/generator.js+271 added-206 removed
2 unmodified lines3 import {PassThrough} from 'node:stream';4 import test from 'ava';5 import getStream, {getStreamAsArray} from 'get-stream';6 import tempfile from 'tempfile';7-import {execa} from '../../index.js';7+import {execa, execaSync} from '../../index.js';8 import {setFixtureDir} from '../helpers/fixtures-dir.js';9 import {getStdio} from '../helpers/stdio.js';10 import {11 foobarString,8 unmodified lines20 outputObjectGenerator,21 uppercaseGenerator,22 uppercaseBufferGenerator,23 appendGenerator,24+ appendAsyncGenerator,25 casedSuffix,26 } from '../helpers/generator.js';27 import {appendDuplex, uppercaseBufferDuplex} from '../helpers/duplex.js';28 import {appendWebTransform, uppercaseBufferWebTransform} from '../helpers/web-transform.js';27 unmodified lines56 getStreamMethod: getStream,57 };58 59 // eslint-disable-next-line max-params59-const testGeneratorInput = async (t, fdNumber, objectMode, addNoopTransform, type) => {60+const testGeneratorInput = async (t, fdNumber, objectMode, addNoopTransform, type, execaMethod) => {61 const {input, generators, output} = getInputObjectMode(objectMode, addNoopTransform, type);61- const {stdout} = await execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [input, ...generators]));62+ const {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [input, ...generators]));63 t.is(stdout, output);64 };65 65-test('Can use generators with result.stdin', testGeneratorInput, 0, false, false, 'generator');66-test('Can use generators with result.stdio[*] as input', testGeneratorInput, 3, false, false, 'generator');67-test('Can use generators with result.stdin, objectMode', testGeneratorInput, 0, true, false, 'generator');68-test('Can use generators with result.stdio[*] as input, objectMode', testGeneratorInput, 3, true, false, 'generator');69-test('Can use generators with result.stdin, noop transform', testGeneratorInput, 0, false, true, 'generator');70-test('Can use generators with result.stdio[*] as input, noop transform', testGeneratorInput, 3, false, true, 'generator');71-test('Can use generators with result.stdin, objectMode, noop transform', testGeneratorInput, 0, true, true, 'generator');72-test('Can use generators with result.stdio[*] as input, objectMode, noop transform', testGeneratorInput, 3, true, true, 'generator');73-test('Can use duplexes with result.stdin', testGeneratorInput, 0, false, false, 'duplex');74-test('Can use duplexes with result.stdio[*] as input', testGeneratorInput, 3, false, false, 'duplex');75-test('Can use duplexes with result.stdin, objectMode', testGeneratorInput, 0, true, false, 'duplex');76-test('Can use duplexes with result.stdio[*] as input, objectMode', testGeneratorInput, 3, true, false, 'duplex');77-test('Can use duplexes with result.stdin, noop transform', testGeneratorInput, 0, false, true, 'duplex');78-test('Can use duplexes with result.stdio[*] as input, noop transform', testGeneratorInput, 3, false, true, 'duplex');79-test('Can use duplexes with result.stdin, objectMode, noop transform', testGeneratorInput, 0, true, true, 'duplex');80-test('Can use duplexes with result.stdio[*] as input, objectMode, noop transform', testGeneratorInput, 3, true, true, 'duplex');81-test('Can use webTransforms with result.stdin', testGeneratorInput, 0, false, false, 'webTransform');82-test('Can use webTransforms with result.stdio[*] as input', testGeneratorInput, 3, false, false, 'webTransform');83-test('Can use webTransforms with result.stdin, objectMode', testGeneratorInput, 0, true, false, 'webTransform');84-test('Can use webTransforms with result.stdio[*] as input, objectMode', testGeneratorInput, 3, true, false, 'webTransform');85-test('Can use webTransforms with result.stdin, noop transform', testGeneratorInput, 0, false, true, 'webTransform');86-test('Can use webTransforms with result.stdio[*] as input, noop transform', testGeneratorInput, 3, false, true, 'webTransform');87-test('Can use webTransforms with result.stdin, objectMode, noop transform', testGeneratorInput, 0, true, true, 'webTransform');88-test('Can use webTransforms with result.stdio[*] as input, objectMode, noop transform', testGeneratorInput, 3, true, true, 'webTransform');66+test('Can use generators with result.stdin', testGeneratorInput, 0, false, false, 'generator', execa);67+test('Can use generators with result.stdio[*] as input', testGeneratorInput, 3, false, false, 'generator', execa);68+test('Can use generators with result.stdin, objectMode', testGeneratorInput, 0, true, false, 'generator', execa);69+test('Can use generators with result.stdio[*] as input, objectMode', testGeneratorInput, 3, true, false, 'generator', execa);70+test('Can use generators with result.stdin, noop transform', testGeneratorInput, 0, false, true, 'generator', execa);71+test('Can use generators with result.stdio[*] as input, noop transform', testGeneratorInput, 3, false, true, 'generator', execa);72+test('Can use generators with result.stdin, objectMode, noop transform', testGeneratorInput, 0, true, true, 'generator', execa);73+test('Can use generators with result.stdio[*] as input, objectMode, noop transform', testGeneratorInput, 3, true, true, 'generator', execa);74+test('Can use generators with result.stdin, sync', testGeneratorInput, 0, false, false, 'generator', execaSync);75+test('Can use generators with result.stdin, objectMode, sync', testGeneratorInput, 0, true, false, 'generator', execaSync);76+test('Can use generators with result.stdin, noop transform, sync', testGeneratorInput, 0, false, true, 'generator', execaSync);77+test('Can use generators with result.stdin, objectMode, noop transform, sync', testGeneratorInput, 0, true, true, 'generator', execaSync);78+test('Can use duplexes with result.stdin', testGeneratorInput, 0, false, false, 'duplex', execa);79+test('Can use duplexes with result.stdio[*] as input', testGeneratorInput, 3, false, false, 'duplex', execa);80+test('Can use duplexes with result.stdin, objectMode', testGeneratorInput, 0, true, false, 'duplex', execa);81+test('Can use duplexes with result.stdio[*] as input, objectMode', testGeneratorInput, 3, true, false, 'duplex', execa);82+test('Can use duplexes with result.stdin, noop transform', testGeneratorInput, 0, false, true, 'duplex', execa);83+test('Can use duplexes with result.stdio[*] as input, noop transform', testGeneratorInput, 3, false, true, 'duplex', execa);84+test('Can use duplexes with result.stdin, objectMode, noop transform', testGeneratorInput, 0, true, true, 'duplex', execa);85+test('Can use duplexes with result.stdio[*] as input, objectMode, noop transform', testGeneratorInput, 3, true, true, 'duplex', execa);86+test('Can use webTransforms with result.stdin', testGeneratorInput, 0, false, false, 'webTransform', execa);87+test('Can use webTransforms with result.stdio[*] as input', testGeneratorInput, 3, false, false, 'webTransform', execa);88+test('Can use webTransforms with result.stdin, objectMode', testGeneratorInput, 0, true, false, 'webTransform', execa);89+test('Can use webTransforms with result.stdio[*] as input, objectMode', testGeneratorInput, 3, true, false, 'webTransform', execa);90+test('Can use webTransforms with result.stdin, noop transform', testGeneratorInput, 0, false, true, 'webTransform', execa);91+test('Can use webTransforms with result.stdio[*] as input, noop transform', testGeneratorInput, 3, false, true, 'webTransform', execa);92+test('Can use webTransforms with result.stdin, objectMode, noop transform', testGeneratorInput, 0, true, true, 'webTransform', execa);93+test('Can use webTransforms with result.stdio[*] as input, objectMode, noop transform', testGeneratorInput, 3, true, true, 'webTransform', execa);94 95 // eslint-disable-next-line max-params96 const testGeneratorInputPipe = async (t, useShortcutProperty, objectMode, addNoopTransform, type, input) => {97 const {generators, output} = getInputObjectMode(objectMode, addNoopTransform, type);74 unmodified lines172 test('Can use webTransforms with subprocess.stdio[*] as input, noop transform', testGeneratorStdioInputPipe, false, true, 'webTransform');173 test('Can use webTransforms with subprocess.stdio[*] as input, objectMode, noop transform', testGeneratorStdioInputPipe, true, true, 'webTransform');174 175 // eslint-disable-next-line max-params171-const testGeneratorOutput = async (t, fdNumber, reject, useShortcutProperty, objectMode, addNoopTransform, type) => {176+const testGeneratorOutput = async (t, fdNumber, reject, useShortcutProperty, objectMode, addNoopTransform, type, execaMethod) => {177 const {generators, output} = getOutputObjectMode(objectMode, addNoopTransform, type);178 const fixtureName = reject ? 'noop-fd.js' : 'noop-fail.js';174- const {stdout, stderr, stdio} = await execa(fixtureName, [`${fdNumber}`, foobarString], {...getStdio(fdNumber, generators), reject});179+ const {stdout, stderr, stdio} = await execaMethod(fixtureName, [`${fdNumber}`, foobarString], {...getStdio(fdNumber, generators), reject});180 const result = useShortcutProperty ? [stdout, stderr][fdNumber - 1] : stdio[fdNumber];181 t.deepEqual(result, output);182 };183 179-test('Can use generators with result.stdio[1]', testGeneratorOutput, 1, true, false, false, false, 'generator');180-test('Can use generators with result.stdout', testGeneratorOutput, 1, true, true, false, false, 'generator');181-test('Can use generators with result.stdio[2]', testGeneratorOutput, 2, true, false, false, false, 'generator');182-test('Can use generators with result.stderr', testGeneratorOutput, 2, true, true, false, false, 'generator');183-test('Can use generators with result.stdio[*] as output', testGeneratorOutput, 3, true, false, false, false, 'generator');184-test('Can use generators with error.stdio[1]', testGeneratorOutput, 1, false, false, false, false, 'generator');185-test('Can use generators with error.stdout', testGeneratorOutput, 1, false, true, false, false, 'generator');186-test('Can use generators with error.stdio[2]', testGeneratorOutput, 2, false, false, false, false, 'generator');187-test('Can use generators with error.stderr', testGeneratorOutput, 2, false, true, false, false, 'generator');188-test('Can use generators with error.stdio[*] as output', testGeneratorOutput, 3, false, false, false, false, 'generator');189-test('Can use generators with result.stdio[1], objectMode', testGeneratorOutput, 1, true, false, true, false, 'generator');190-test('Can use generators with result.stdout, objectMode', testGeneratorOutput, 1, true, true, true, false, 'generator');191-test('Can use generators with result.stdio[2], objectMode', testGeneratorOutput, 2, true, false, true, false, 'generator');192-test('Can use generators with result.stderr, objectMode', testGeneratorOutput, 2, true, true, true, false, 'generator');193-test('Can use generators with result.stdio[*] as output, objectMode', testGeneratorOutput, 3, true, false, true, false, 'generator');194-test('Can use generators with error.stdio[1], objectMode', testGeneratorOutput, 1, false, false, true, false, 'generator');195-test('Can use generators with error.stdout, objectMode', testGeneratorOutput, 1, false, true, true, false, 'generator');196-test('Can use generators with error.stdio[2], objectMode', testGeneratorOutput, 2, false, false, true, false, 'generator');197-test('Can use generators with error.stderr, objectMode', testGeneratorOutput, 2, false, true, true, false, 'generator');198-test('Can use generators with error.stdio[*] as output, objectMode', testGeneratorOutput, 3, false, false, true, false, 'generator');199-test('Can use generators with result.stdio[1], noop transform', testGeneratorOutput, 1, true, false, false, true, 'generator');200-test('Can use generators with result.stdout, noop transform', testGeneratorOutput, 1, true, true, false, true, 'generator');201-test('Can use generators with result.stdio[2], noop transform', testGeneratorOutput, 2, true, false, false, true, 'generator');202-test('Can use generators with result.stderr, noop transform', testGeneratorOutput, 2, true, true, false, true, 'generator');203-test('Can use generators with result.stdio[*] as output, noop transform', testGeneratorOutput, 3, true, false, false, true, 'generator');204-test('Can use generators with error.stdio[1], noop transform', testGeneratorOutput, 1, false, false, false, true, 'generator');205-test('Can use generators with error.stdout, noop transform', testGeneratorOutput, 1, false, true, false, true, 'generator');206-test('Can use generators with error.stdio[2], noop transform', testGeneratorOutput, 2, false, false, false, true, 'generator');207-test('Can use generators with error.stderr, noop transform', testGeneratorOutput, 2, false, true, false, true, 'generator');208-test('Can use generators with error.stdio[*] as output, noop transform', testGeneratorOutput, 3, false, false, false, true, 'generator');209-test('Can use generators with result.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, true, false, true, true, 'generator');210-test('Can use generators with result.stdout, objectMode, noop transform', testGeneratorOutput, 1, true, true, true, true, 'generator');211-test('Can use generators with result.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, true, false, true, true, 'generator');212-test('Can use generators with result.stderr, objectMode, noop transform', testGeneratorOutput, 2, true, true, true, true, 'generator');213-test('Can use generators with result.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, true, false, true, true, 'generator');214-test('Can use generators with error.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, false, false, true, true, 'generator');215-test('Can use generators with error.stdout, objectMode, noop transform', testGeneratorOutput, 1, false, true, true, true, 'generator');216-test('Can use generators with error.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, false, false, true, true, 'generator');217-test('Can use generators with error.stderr, objectMode, noop transform', testGeneratorOutput, 2, false, true, true, true, 'generator');218-test('Can use generators with error.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, false, false, true, true, 'generator');219-test('Can use duplexes with result.stdio[1]', testGeneratorOutput, 1, true, false, false, false, 'duplex');220-test('Can use duplexes with result.stdout', testGeneratorOutput, 1, true, true, false, false, 'duplex');221-test('Can use duplexes with result.stdio[2]', testGeneratorOutput, 2, true, false, false, false, 'duplex');222-test('Can use duplexes with result.stderr', testGeneratorOutput, 2, true, true, false, false, 'duplex');223-test('Can use duplexes with result.stdio[*] as output', testGeneratorOutput, 3, true, false, false, false, 'duplex');224-test('Can use duplexes with error.stdio[1]', testGeneratorOutput, 1, false, false, false, false, 'duplex');225-test('Can use duplexes with error.stdout', testGeneratorOutput, 1, false, true, false, false, 'duplex');226-test('Can use duplexes with error.stdio[2]', testGeneratorOutput, 2, false, false, false, false, 'duplex');227-test('Can use duplexes with error.stderr', testGeneratorOutput, 2, false, true, false, false, 'duplex');228-test('Can use duplexes with error.stdio[*] as output', testGeneratorOutput, 3, false, false, false, false, 'duplex');229-test('Can use duplexes with result.stdio[1], objectMode', testGeneratorOutput, 1, true, false, true, false, 'duplex');230-test('Can use duplexes with result.stdout, objectMode', testGeneratorOutput, 1, true, true, true, false, 'duplex');231-test('Can use duplexes with result.stdio[2], objectMode', testGeneratorOutput, 2, true, false, true, false, 'duplex');232-test('Can use duplexes with result.stderr, objectMode', testGeneratorOutput, 2, true, true, true, false, 'duplex');233-test('Can use duplexes with result.stdio[*] as output, objectMode', testGeneratorOutput, 3, true, false, true, false, 'duplex');234-test('Can use duplexes with error.stdio[1], objectMode', testGeneratorOutput, 1, false, false, true, false, 'duplex');235-test('Can use duplexes with error.stdout, objectMode', testGeneratorOutput, 1, false, true, true, false, 'duplex');236-test('Can use duplexes with error.stdio[2], objectMode', testGeneratorOutput, 2, false, false, true, false, 'duplex');237-test('Can use duplexes with error.stderr, objectMode', testGeneratorOutput, 2, false, true, true, false, 'duplex');238-test('Can use duplexes with error.stdio[*] as output, objectMode', testGeneratorOutput, 3, false, false, true, false, 'duplex');239-test('Can use duplexes with result.stdio[1], noop transform', testGeneratorOutput, 1, true, false, false, true, 'duplex');240-test('Can use duplexes with result.stdout, noop transform', testGeneratorOutput, 1, true, true, false, true, 'duplex');241-test('Can use duplexes with result.stdio[2], noop transform', testGeneratorOutput, 2, true, false, false, true, 'duplex');242-test('Can use duplexes with result.stderr, noop transform', testGeneratorOutput, 2, true, true, false, true, 'duplex');243-test('Can use duplexes with result.stdio[*] as output, noop transform', testGeneratorOutput, 3, true, false, false, true, 'duplex');244-test('Can use duplexes with error.stdio[1], noop transform', testGeneratorOutput, 1, false, false, false, true, 'duplex');245-test('Can use duplexes with error.stdout, noop transform', testGeneratorOutput, 1, false, true, false, true, 'duplex');246-test('Can use duplexes with error.stdio[2], noop transform', testGeneratorOutput, 2, false, false, false, true, 'duplex');247-test('Can use duplexes with error.stderr, noop transform', testGeneratorOutput, 2, false, true, false, true, 'duplex');248-test('Can use duplexes with error.stdio[*] as output, noop transform', testGeneratorOutput, 3, false, false, false, true, 'duplex');249-test('Can use duplexes with result.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, true, false, true, true, 'duplex');250-test('Can use duplexes with result.stdout, objectMode, noop transform', testGeneratorOutput, 1, true, true, true, true, 'duplex');251-test('Can use duplexes with result.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, true, false, true, true, 'duplex');252-test('Can use duplexes with result.stderr, objectMode, noop transform', testGeneratorOutput, 2, true, true, true, true, 'duplex');253-test('Can use duplexes with result.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, true, false, true, true, 'duplex');254-test('Can use duplexes with error.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, false, false, true, true, 'duplex');255-test('Can use duplexes with error.stdout, objectMode, noop transform', testGeneratorOutput, 1, false, true, true, true, 'duplex');256-test('Can use duplexes with error.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, false, false, true, true, 'duplex');257-test('Can use duplexes with error.stderr, objectMode, noop transform', testGeneratorOutput, 2, false, true, true, true, 'duplex');258-test('Can use duplexes with error.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, false, false, true, true, 'duplex');259-test('Can use webTransforms with result.stdio[1]', testGeneratorOutput, 1, true, false, false, false, 'webTransform');260-test('Can use webTransforms with result.stdout', testGeneratorOutput, 1, true, true, false, false, 'webTransform');261-test('Can use webTransforms with result.stdio[2]', testGeneratorOutput, 2, true, false, false, false, 'webTransform');262-test('Can use webTransforms with result.stderr', testGeneratorOutput, 2, true, true, false, false, 'webTransform');263-test('Can use webTransforms with result.stdio[*] as output', testGeneratorOutput, 3, true, false, false, false, 'webTransform');264-test('Can use webTransforms with error.stdio[1]', testGeneratorOutput, 1, false, false, false, false, 'webTransform');265-test('Can use webTransforms with error.stdout', testGeneratorOutput, 1, false, true, false, false, 'webTransform');266-test('Can use webTransforms with error.stdio[2]', testGeneratorOutput, 2, false, false, false, false, 'webTransform');267-test('Can use webTransforms with error.stderr', testGeneratorOutput, 2, false, true, false, false, 'webTransform');268-test('Can use webTransforms with error.stdio[*] as output', testGeneratorOutput, 3, false, false, false, false, 'webTransform');269-test('Can use webTransforms with result.stdio[1], objectMode', testGeneratorOutput, 1, true, false, true, false, 'webTransform');270-test('Can use webTransforms with result.stdout, objectMode', testGeneratorOutput, 1, true, true, true, false, 'webTransform');271-test('Can use webTransforms with result.stdio[2], objectMode', testGeneratorOutput, 2, true, false, true, false, 'webTransform');272-test('Can use webTransforms with result.stderr, objectMode', testGeneratorOutput, 2, true, true, true, false, 'webTransform');273-test('Can use webTransforms with result.stdio[*] as output, objectMode', testGeneratorOutput, 3, true, false, true, false, 'webTransform');274-test('Can use webTransforms with error.stdio[1], objectMode', testGeneratorOutput, 1, false, false, true, false, 'webTransform');275-test('Can use webTransforms with error.stdout, objectMode', testGeneratorOutput, 1, false, true, true, false, 'webTransform');276-test('Can use webTransforms with error.stdio[2], objectMode', testGeneratorOutput, 2, false, false, true, false, 'webTransform');277-test('Can use webTransforms with error.stderr, objectMode', testGeneratorOutput, 2, false, true, true, false, 'webTransform');278-test('Can use webTransforms with error.stdio[*] as output, objectMode', testGeneratorOutput, 3, false, false, true, false, 'webTransform');279-test('Can use webTransforms with result.stdio[1], noop transform', testGeneratorOutput, 1, true, false, false, true, 'webTransform');280-test('Can use webTransforms with result.stdout, noop transform', testGeneratorOutput, 1, true, true, false, true, 'webTransform');281-test('Can use webTransforms with result.stdio[2], noop transform', testGeneratorOutput, 2, true, false, false, true, 'webTransform');282-test('Can use webTransforms with result.stderr, noop transform', testGeneratorOutput, 2, true, true, false, true, 'webTransform');283-test('Can use webTransforms with result.stdio[*] as output, noop transform', testGeneratorOutput, 3, true, false, false, true, 'webTransform');284-test('Can use webTransforms with error.stdio[1], noop transform', testGeneratorOutput, 1, false, false, false, true, 'webTransform');285-test('Can use webTransforms with error.stdout, noop transform', testGeneratorOutput, 1, false, true, false, true, 'webTransform');286-test('Can use webTransforms with error.stdio[2], noop transform', testGeneratorOutput, 2, false, false, false, true, 'webTransform');287-test('Can use webTransforms with error.stderr, noop transform', testGeneratorOutput, 2, false, true, false, true, 'webTransform');288-test('Can use webTransforms with error.stdio[*] as output, noop transform', testGeneratorOutput, 3, false, false, false, true, 'webTransform');289-test('Can use webTransforms with result.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, true, false, true, true, 'webTransform');290-test('Can use webTransforms with result.stdout, objectMode, noop transform', testGeneratorOutput, 1, true, true, true, true, 'webTransform');291-test('Can use webTransforms with result.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, true, false, true, true, 'webTransform');292-test('Can use webTransforms with result.stderr, objectMode, noop transform', testGeneratorOutput, 2, true, true, true, true, 'webTransform');293-test('Can use webTransforms with result.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, true, false, true, true, 'webTransform');294-test('Can use webTransforms with error.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, false, false, true, true, 'webTransform');295-test('Can use webTransforms with error.stdout, objectMode, noop transform', testGeneratorOutput, 1, false, true, true, true, 'webTransform');296-test('Can use webTransforms with error.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, false, false, true, true, 'webTransform');297-test('Can use webTransforms with error.stderr, objectMode, noop transform', testGeneratorOutput, 2, false, true, true, true, 'webTransform');298-test('Can use webTransforms with error.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, false, false, true, true, 'webTransform');184+test('Can use generators with result.stdio[1]', testGeneratorOutput, 1, true, false, false, false, 'generator', execa);185+test('Can use generators with result.stdout', testGeneratorOutput, 1, true, true, false, false, 'generator', execa);186+test('Can use generators with result.stdio[2]', testGeneratorOutput, 2, true, false, false, false, 'generator', execa);187+test('Can use generators with result.stderr', testGeneratorOutput, 2, true, true, false, false, 'generator', execa);188+test('Can use generators with result.stdio[*] as output', testGeneratorOutput, 3, true, false, false, false, 'generator', execa);189+test('Can use generators with error.stdio[1]', testGeneratorOutput, 1, false, false, false, false, 'generator', execa);190+test('Can use generators with error.stdout', testGeneratorOutput, 1, false, true, false, false, 'generator', execa);191+test('Can use generators with error.stdio[2]', testGeneratorOutput, 2, false, false, false, false, 'generator', execa);192+test('Can use generators with error.stderr', testGeneratorOutput, 2, false, true, false, false, 'generator', execa);193+test('Can use generators with error.stdio[*] as output', testGeneratorOutput, 3, false, false, false, false, 'generator', execa);194+test('Can use generators with result.stdio[1], objectMode', testGeneratorOutput, 1, true, false, true, false, 'generator', execa);195+test('Can use generators with result.stdout, objectMode', testGeneratorOutput, 1, true, true, true, false, 'generator', execa);196+test('Can use generators with result.stdio[2], objectMode', testGeneratorOutput, 2, true, false, true, false, 'generator', execa);197+test('Can use generators with result.stderr, objectMode', testGeneratorOutput, 2, true, true, true, false, 'generator', execa);198+test('Can use generators with result.stdio[*] as output, objectMode', testGeneratorOutput, 3, true, false, true, false, 'generator', execa);199+test('Can use generators with error.stdio[1], objectMode', testGeneratorOutput, 1, false, false, true, false, 'generator', execa);200+test('Can use generators with error.stdout, objectMode', testGeneratorOutput, 1, false, true, true, false, 'generator', execa);201+test('Can use generators with error.stdio[2], objectMode', testGeneratorOutput, 2, false, false, true, false, 'generator', execa);202+test('Can use generators with error.stderr, objectMode', testGeneratorOutput, 2, false, true, true, false, 'generator', execa);203+test('Can use generators with error.stdio[*] as output, objectMode', testGeneratorOutput, 3, false, false, true, false, 'generator', execa);204+test('Can use generators with result.stdio[1], noop transform', testGeneratorOutput, 1, true, false, false, true, 'generator', execa);205+test('Can use generators with result.stdout, noop transform', testGeneratorOutput, 1, true, true, false, true, 'generator', execa);206+test('Can use generators with result.stdio[2], noop transform', testGeneratorOutput, 2, true, false, false, true, 'generator', execa);207+test('Can use generators with result.stderr, noop transform', testGeneratorOutput, 2, true, true, false, true, 'generator', execa);208+test('Can use generators with result.stdio[*] as output, noop transform', testGeneratorOutput, 3, true, false, false, true, 'generator', execa);209+test('Can use generators with error.stdio[1], noop transform', testGeneratorOutput, 1, false, false, false, true, 'generator', execa);210+test('Can use generators with error.stdout, noop transform', testGeneratorOutput, 1, false, true, false, true, 'generator', execa);211+test('Can use generators with error.stdio[2], noop transform', testGeneratorOutput, 2, false, false, false, true, 'generator', execa);212+test('Can use generators with error.stderr, noop transform', testGeneratorOutput, 2, false, true, false, true, 'generator', execa);213+test('Can use generators with error.stdio[*] as output, noop transform', testGeneratorOutput, 3, false, false, false, true, 'generator', execa);214+test('Can use generators with result.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, true, false, true, true, 'generator', execa);215+test('Can use generators with result.stdout, objectMode, noop transform', testGeneratorOutput, 1, true, true, true, true, 'generator', execa);216+test('Can use generators with result.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, true, false, true, true, 'generator', execa);217+test('Can use generators with result.stderr, objectMode, noop transform', testGeneratorOutput, 2, true, true, true, true, 'generator', execa);218+test('Can use generators with result.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, true, false, true, true, 'generator', execa);219+test('Can use generators with error.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, false, false, true, true, 'generator', execa);220+test('Can use generators with error.stdout, objectMode, noop transform', testGeneratorOutput, 1, false, true, true, true, 'generator', execa);221+test('Can use generators with error.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, false, false, true, true, 'generator', execa);222+test('Can use generators with error.stderr, objectMode, noop transform', testGeneratorOutput, 2, false, true, true, true, 'generator', execa);223+test('Can use generators with error.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, false, false, true, true, 'generator', execa);224+test('Can use generators with result.stdio[1], sync', testGeneratorOutput, 1, true, false, false, false, 'generator', execaSync);225+test('Can use generators with result.stdout, sync', testGeneratorOutput, 1, true, true, false, false, 'generator', execaSync);226+test('Can use generators with result.stdio[2], sync', testGeneratorOutput, 2, true, false, false, false, 'generator', execaSync);227+test('Can use generators with result.stderr, sync', testGeneratorOutput, 2, true, true, false, false, 'generator', execaSync);228+test('Can use generators with result.stdio[*] as output, sync', testGeneratorOutput, 3, true, false, false, false, 'generator', execaSync);229+test('Can use generators with error.stdio[1], sync', testGeneratorOutput, 1, false, false, false, false, 'generator', execaSync);230+test('Can use generators with error.stdout, sync', testGeneratorOutput, 1, false, true, false, false, 'generator', execaSync);231+test('Can use generators with error.stdio[2], sync', testGeneratorOutput, 2, false, false, false, false, 'generator', execaSync);232+test('Can use generators with error.stderr, sync', testGeneratorOutput, 2, false, true, false, false, 'generator', execaSync);233+test('Can use generators with error.stdio[*] as output, sync', testGeneratorOutput, 3, false, false, false, false, 'generator', execaSync);234+test('Can use generators with result.stdio[1], objectMode, sync', testGeneratorOutput, 1, true, false, true, false, 'generator', execaSync);235+test('Can use generators with result.stdout, objectMode, sync', testGeneratorOutput, 1, true, true, true, false, 'generator', execaSync);236+test('Can use generators with result.stdio[2], objectMode, sync', testGeneratorOutput, 2, true, false, true, false, 'generator', execaSync);237+test('Can use generators with result.stderr, objectMode, sync', testGeneratorOutput, 2, true, true, true, false, 'generator', execaSync);238+test('Can use generators with result.stdio[*] as output, objectMode, sync', testGeneratorOutput, 3, true, false, true, false, 'generator', execaSync);239+test('Can use generators with error.stdio[1], objectMode, sync', testGeneratorOutput, 1, false, false, true, false, 'generator', execaSync);240+test('Can use generators with error.stdout, objectMode, sync', testGeneratorOutput, 1, false, true, true, false, 'generator', execaSync);241+test('Can use generators with error.stdio[2], objectMode, sync', testGeneratorOutput, 2, false, false, true, false, 'generator', execaSync);242+test('Can use generators with error.stderr, objectMode, sync', testGeneratorOutput, 2, false, true, true, false, 'generator', execaSync);243+test('Can use generators with error.stdio[*] as output, objectMode, sync', testGeneratorOutput, 3, false, false, true, false, 'generator', execaSync);244+test('Can use generators with result.stdio[1], noop transform, sync', testGeneratorOutput, 1, true, false, false, true, 'generator', execaSync);245+test('Can use generators with result.stdout, noop transform, sync', testGeneratorOutput, 1, true, true, false, true, 'generator', execaSync);246+test('Can use generators with result.stdio[2], noop transform, sync', testGeneratorOutput, 2, true, false, false, true, 'generator', execaSync);247+test('Can use generators with result.stderr, noop transform, sync', testGeneratorOutput, 2, true, true, false, true, 'generator', execaSync);248+test('Can use generators with result.stdio[*] as output, noop transform, sync', testGeneratorOutput, 3, true, false, false, true, 'generator', execaSync);249+test('Can use generators with error.stdio[1], noop transform, sync', testGeneratorOutput, 1, false, false, false, true, 'generator', execaSync);250+test('Can use generators with error.stdout, noop transform, sync', testGeneratorOutput, 1, false, true, false, true, 'generator', execaSync);251+test('Can use generators with error.stdio[2], noop transform, sync', testGeneratorOutput, 2, false, false, false, true, 'generator', execaSync);252+test('Can use generators with error.stderr, noop transform, sync', testGeneratorOutput, 2, false, true, false, true, 'generator', execaSync);253+test('Can use generators with error.stdio[*] as output, noop transform, sync', testGeneratorOutput, 3, false, false, false, true, 'generator', execaSync);254+test('Can use generators with result.stdio[1], objectMode, noop transform, sync', testGeneratorOutput, 1, true, false, true, true, 'generator', execaSync);255+test('Can use generators with result.stdout, objectMode, noop transform, sync', testGeneratorOutput, 1, true, true, true, true, 'generator', execaSync);256+test('Can use generators with result.stdio[2], objectMode, noop transform, sync', testGeneratorOutput, 2, true, false, true, true, 'generator', execaSync);257+test('Can use generators with result.stderr, objectMode, noop transform, sync', testGeneratorOutput, 2, true, true, true, true, 'generator', execaSync);258+test('Can use generators with result.stdio[*] as output, objectMode, noop transform, sync', testGeneratorOutput, 3, true, false, true, true, 'generator', execaSync);259+test('Can use generators with error.stdio[1], objectMode, noop transform, sync', testGeneratorOutput, 1, false, false, true, true, 'generator', execaSync);260+test('Can use generators with error.stdout, objectMode, noop transform, sync', testGeneratorOutput, 1, false, true, true, true, 'generator', execaSync);261+test('Can use generators with error.stdio[2], objectMode, noop transform, sync', testGeneratorOutput, 2, false, false, true, true, 'generator', execaSync);262+test('Can use generators with error.stderr, objectMode, noop transform, sync', testGeneratorOutput, 2, false, true, true, true, 'generator', execaSync);263+test('Can use generators with error.stdio[*] as output, objectMode, noop transform, sync', testGeneratorOutput, 3, false, false, true, true, 'generator', execaSync);264+test('Can use duplexes with result.stdio[1]', testGeneratorOutput, 1, true, false, false, false, 'duplex', execa);265+test('Can use duplexes with result.stdout', testGeneratorOutput, 1, true, true, false, false, 'duplex', execa);266+test('Can use duplexes with result.stdio[2]', testGeneratorOutput, 2, true, false, false, false, 'duplex', execa);267+test('Can use duplexes with result.stderr', testGeneratorOutput, 2, true, true, false, false, 'duplex', execa);268+test('Can use duplexes with result.stdio[*] as output', testGeneratorOutput, 3, true, false, false, false, 'duplex', execa);269+test('Can use duplexes with error.stdio[1]', testGeneratorOutput, 1, false, false, false, false, 'duplex', execa);270+test('Can use duplexes with error.stdout', testGeneratorOutput, 1, false, true, false, false, 'duplex', execa);271+test('Can use duplexes with error.stdio[2]', testGeneratorOutput, 2, false, false, false, false, 'duplex', execa);272+test('Can use duplexes with error.stderr', testGeneratorOutput, 2, false, true, false, false, 'duplex', execa);273+test('Can use duplexes with error.stdio[*] as output', testGeneratorOutput, 3, false, false, false, false, 'duplex', execa);274+test('Can use duplexes with result.stdio[1], objectMode', testGeneratorOutput, 1, true, false, true, false, 'duplex', execa);275+test('Can use duplexes with result.stdout, objectMode', testGeneratorOutput, 1, true, true, true, false, 'duplex', execa);276+test('Can use duplexes with result.stdio[2], objectMode', testGeneratorOutput, 2, true, false, true, false, 'duplex', execa);277+test('Can use duplexes with result.stderr, objectMode', testGeneratorOutput, 2, true, true, true, false, 'duplex', execa);278+test('Can use duplexes with result.stdio[*] as output, objectMode', testGeneratorOutput, 3, true, false, true, false, 'duplex', execa);279+test('Can use duplexes with error.stdio[1], objectMode', testGeneratorOutput, 1, false, false, true, false, 'duplex', execa);280+test('Can use duplexes with error.stdout, objectMode', testGeneratorOutput, 1, false, true, true, false, 'duplex', execa);281+test('Can use duplexes with error.stdio[2], objectMode', testGeneratorOutput, 2, false, false, true, false, 'duplex', execa);282+test('Can use duplexes with error.stderr, objectMode', testGeneratorOutput, 2, false, true, true, false, 'duplex', execa);283+test('Can use duplexes with error.stdio[*] as output, objectMode', testGeneratorOutput, 3, false, false, true, false, 'duplex', execa);284+test('Can use duplexes with result.stdio[1], noop transform', testGeneratorOutput, 1, true, false, false, true, 'duplex', execa);285+test('Can use duplexes with result.stdout, noop transform', testGeneratorOutput, 1, true, true, false, true, 'duplex', execa);286+test('Can use duplexes with result.stdio[2], noop transform', testGeneratorOutput, 2, true, false, false, true, 'duplex', execa);287+test('Can use duplexes with result.stderr, noop transform', testGeneratorOutput, 2, true, true, false, true, 'duplex', execa);288+test('Can use duplexes with result.stdio[*] as output, noop transform', testGeneratorOutput, 3, true, false, false, true, 'duplex', execa);289+test('Can use duplexes with error.stdio[1], noop transform', testGeneratorOutput, 1, false, false, false, true, 'duplex', execa);290+test('Can use duplexes with error.stdout, noop transform', testGeneratorOutput, 1, false, true, false, true, 'duplex', execa);291+test('Can use duplexes with error.stdio[2], noop transform', testGeneratorOutput, 2, false, false, false, true, 'duplex', execa);292+test('Can use duplexes with error.stderr, noop transform', testGeneratorOutput, 2, false, true, false, true, 'duplex', execa);293+test('Can use duplexes with error.stdio[*] as output, noop transform', testGeneratorOutput, 3, false, false, false, true, 'duplex', execa);294+test('Can use duplexes with result.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, true, false, true, true, 'duplex', execa);295+test('Can use duplexes with result.stdout, objectMode, noop transform', testGeneratorOutput, 1, true, true, true, true, 'duplex', execa);296+test('Can use duplexes with result.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, true, false, true, true, 'duplex', execa);297+test('Can use duplexes with result.stderr, objectMode, noop transform', testGeneratorOutput, 2, true, true, true, true, 'duplex', execa);298+test('Can use duplexes with result.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, true, false, true, true, 'duplex', execa);299+test('Can use duplexes with error.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, false, false, true, true, 'duplex', execa);300+test('Can use duplexes with error.stdout, objectMode, noop transform', testGeneratorOutput, 1, false, true, true, true, 'duplex', execa);301+test('Can use duplexes with error.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, false, false, true, true, 'duplex', execa);302+test('Can use duplexes with error.stderr, objectMode, noop transform', testGeneratorOutput, 2, false, true, true, true, 'duplex', execa);303+test('Can use duplexes with error.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, false, false, true, true, 'duplex', execa);304+test('Can use webTransforms with result.stdio[1]', testGeneratorOutput, 1, true, false, false, false, 'webTransform', execa);305+test('Can use webTransforms with result.stdout', testGeneratorOutput, 1, true, true, false, false, 'webTransform', execa);306+test('Can use webTransforms with result.stdio[2]', testGeneratorOutput, 2, true, false, false, false, 'webTransform', execa);307+test('Can use webTransforms with result.stderr', testGeneratorOutput, 2, true, true, false, false, 'webTransform', execa);308+test('Can use webTransforms with result.stdio[*] as output', testGeneratorOutput, 3, true, false, false, false, 'webTransform', execa);309+test('Can use webTransforms with error.stdio[1]', testGeneratorOutput, 1, false, false, false, false, 'webTransform', execa);310+test('Can use webTransforms with error.stdout', testGeneratorOutput, 1, false, true, false, false, 'webTransform', execa);311+test('Can use webTransforms with error.stdio[2]', testGeneratorOutput, 2, false, false, false, false, 'webTransform', execa);312+test('Can use webTransforms with error.stderr', testGeneratorOutput, 2, false, true, false, false, 'webTransform', execa);313+test('Can use webTransforms with error.stdio[*] as output', testGeneratorOutput, 3, false, false, false, false, 'webTransform', execa);314+test('Can use webTransforms with result.stdio[1], objectMode', testGeneratorOutput, 1, true, false, true, false, 'webTransform', execa);315+test('Can use webTransforms with result.stdout, objectMode', testGeneratorOutput, 1, true, true, true, false, 'webTransform', execa);316+test('Can use webTransforms with result.stdio[2], objectMode', testGeneratorOutput, 2, true, false, true, false, 'webTransform', execa);317+test('Can use webTransforms with result.stderr, objectMode', testGeneratorOutput, 2, true, true, true, false, 'webTransform', execa);318+test('Can use webTransforms with result.stdio[*] as output, objectMode', testGeneratorOutput, 3, true, false, true, false, 'webTransform', execa);319+test('Can use webTransforms with error.stdio[1], objectMode', testGeneratorOutput, 1, false, false, true, false, 'webTransform', execa);320+test('Can use webTransforms with error.stdout, objectMode', testGeneratorOutput, 1, false, true, true, false, 'webTransform', execa);321+test('Can use webTransforms with error.stdio[2], objectMode', testGeneratorOutput, 2, false, false, true, false, 'webTransform', execa);322+test('Can use webTransforms with error.stderr, objectMode', testGeneratorOutput, 2, false, true, true, false, 'webTransform', execa);323+test('Can use webTransforms with error.stdio[*] as output, objectMode', testGeneratorOutput, 3, false, false, true, false, 'webTransform', execa);324+test('Can use webTransforms with result.stdio[1], noop transform', testGeneratorOutput, 1, true, false, false, true, 'webTransform', execa);325+test('Can use webTransforms with result.stdout, noop transform', testGeneratorOutput, 1, true, true, false, true, 'webTransform', execa);326+test('Can use webTransforms with result.stdio[2], noop transform', testGeneratorOutput, 2, true, false, false, true, 'webTransform', execa);327+test('Can use webTransforms with result.stderr, noop transform', testGeneratorOutput, 2, true, true, false, true, 'webTransform', execa);328+test('Can use webTransforms with result.stdio[*] as output, noop transform', testGeneratorOutput, 3, true, false, false, true, 'webTransform', execa);329+test('Can use webTransforms with error.stdio[1], noop transform', testGeneratorOutput, 1, false, false, false, true, 'webTransform', execa);330+test('Can use webTransforms with error.stdout, noop transform', testGeneratorOutput, 1, false, true, false, true, 'webTransform', execa);331+test('Can use webTransforms with error.stdio[2], noop transform', testGeneratorOutput, 2, false, false, false, true, 'webTransform', execa);332+test('Can use webTransforms with error.stderr, noop transform', testGeneratorOutput, 2, false, true, false, true, 'webTransform', execa);333+test('Can use webTransforms with error.stdio[*] as output, noop transform', testGeneratorOutput, 3, false, false, false, true, 'webTransform', execa);334+test('Can use webTransforms with result.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, true, false, true, true, 'webTransform', execa);335+test('Can use webTransforms with result.stdout, objectMode, noop transform', testGeneratorOutput, 1, true, true, true, true, 'webTransform', execa);336+test('Can use webTransforms with result.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, true, false, true, true, 'webTransform', execa);337+test('Can use webTransforms with result.stderr, objectMode, noop transform', testGeneratorOutput, 2, true, true, true, true, 'webTransform', execa);338+test('Can use webTransforms with result.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, true, false, true, true, 'webTransform', execa);339+test('Can use webTransforms with error.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, false, false, true, true, 'webTransform', execa);340+test('Can use webTransforms with error.stdout, objectMode, noop transform', testGeneratorOutput, 1, false, true, true, true, 'webTransform', execa);341+test('Can use webTransforms with error.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, false, false, true, true, 'webTransform', execa);342+test('Can use webTransforms with error.stderr, objectMode, noop transform', testGeneratorOutput, 2, false, true, true, true, 'webTransform', execa);343+test('Can use webTransforms with error.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, false, false, true, true, 'webTransform', execa);344 345 // eslint-disable-next-line max-params346 const testGeneratorOutputPipe = async (t, fdNumber, useShortcutProperty, objectMode, addNoopTransform, type) => {347 const {generators, output, getStreamMethod} = getOutputObjectMode(objectMode, addNoopTransform, type, true);156 unmodified lines504 test('Can use generators with error.all = pipe + transform, objectMode, encoding "buffer"', testGeneratorAll, false, 'buffer', true, true, false);505 test('Can use generators with result.all = pipe + transform, objectMode, encoding "hex"', testGeneratorAll, true, 'hex', true, true, false);506 test('Can use generators with error.all = pipe + transform, objectMode, encoding "hex"', testGeneratorAll, false, 'hex', true, true, false);507 463-const testInputOption = async (t, type) => {464- const {stdout} = await execa('stdin-fd.js', ['0'], {stdin: generatorsMap[type].uppercase(), input: foobarUint8Array});508+const testInputOption = async (t, type, execaMethod) => {509+ const {stdout} = await execaMethod('stdin-fd.js', ['0'], {stdin: generatorsMap[type].uppercase(), input: foobarUint8Array});510 t.is(stdout, foobarUppercase);511 };512 468-test('Can use generators with input option', testInputOption, 'generator');469-test('Can use duplexes with input option', testInputOption, 'duplex');470-test('Can use webTransforms with input option', testInputOption, 'webTransform');513+test('Can use generators with input option', testInputOption, 'generator', execa);514+test('Can use generators with input option, sync', testInputOption, 'generator', execaSync);515+test('Can use duplexes with input option', testInputOption, 'duplex', execa);516+test('Can use webTransforms with input option', testInputOption, 'webTransform', execa);517 472-const testInputFile = async (t, getOptions, reversed) => {518+// eslint-disable-next-line max-params519+const testInputFile = async (t, stdinOption, useInputFile, reversed, execaMethod) => {520 const filePath = tempfile();521 await writeFile(filePath, foobarString);475- const {stdin, ...options} = getOptions(filePath);476- const reversedStdin = reversed ? stdin.reverse() : stdin;477- const {stdout} = await execa('stdin-fd.js', ['0'], {...options, stdin: reversedStdin});522+ const options = useInputFile523+ ? {inputFile: filePath, stdin: stdinOption}524+ : {stdin: [{file: filePath}, stdinOption]};525+ options.stdin = reversed ? options.stdin.reverse() : options.stdin;526+ const {stdout} = await execaMethod('stdin-fd.js', ['0'], options);527 t.is(stdout, foobarUppercase);528 await rm(filePath);529 };530 482-test('Can use generators with a file as input', testInputFile, filePath => ({stdin: [{file: filePath}, uppercaseGenerator()]}), false);483-test('Can use generators with a file as input, reversed', testInputFile, filePath => ({stdin: [{file: filePath}, uppercaseGenerator()]}), true);484-test('Can use generators with inputFile option', testInputFile, filePath => ({inputFile: filePath, stdin: uppercaseGenerator()}), false);485-test('Can use duplexes with a file as input', testInputFile, filePath => ({stdin: [{file: filePath}, uppercaseBufferDuplex()]}), false);486-test('Can use duplexes with a file as input, reversed', testInputFile, filePath => ({stdin: [{file: filePath}, uppercaseBufferDuplex()]}), true);487-test('Can use duplexes with inputFile option', testInputFile, filePath => ({inputFile: filePath, stdin: uppercaseBufferDuplex()}), false);488-test('Can use webTransforms with a file as input', testInputFile, filePath => ({stdin: [{file: filePath}, uppercaseBufferWebTransform()]}), false);489-test('Can use webTransforms with a file as input, reversed', testInputFile, filePath => ({stdin: [{file: filePath}, uppercaseBufferWebTransform()]}), true);490-test('Can use webTransforms with inputFile option', testInputFile, filePath => ({inputFile: filePath, stdin: uppercaseBufferWebTransform()}), false);531+test('Can use generators with a file as input', testInputFile, uppercaseGenerator(), false, false, execa);532+test('Can use generators with a file as input, reversed', testInputFile, uppercaseGenerator(), false, true, execa);533+test('Can use generators with inputFile option', testInputFile, uppercaseGenerator(), true, false, execa);534+test('Can use generators with a file as input, sync', testInputFile, uppercaseGenerator(), false, false, execaSync);535+test('Can use generators with a file as input, reversed, sync', testInputFile, uppercaseGenerator(), false, true, execaSync);536+test('Can use generators with inputFile option, sync', testInputFile, uppercaseGenerator(), true, false, execaSync);537+test('Can use duplexes with a file as input', testInputFile, uppercaseBufferDuplex(), false, false, execa);538+test('Can use duplexes with a file as input, reversed', testInputFile, uppercaseBufferDuplex(), false, true, execa);539+test('Can use duplexes with inputFile option', testInputFile, uppercaseBufferDuplex(), true, false, execa);540+test('Can use webTransforms with a file as input', testInputFile, uppercaseBufferWebTransform(), false, false, execa);541+test('Can use webTransforms with a file as input, reversed', testInputFile, uppercaseBufferWebTransform(), false, true, execa);542+test('Can use webTransforms with inputFile option', testInputFile, uppercaseBufferWebTransform(), true, false, execa);543 492-const testOutputFile = async (t, reversed, type) => {544+const testOutputFile = async (t, reversed, type, execaMethod) => {545 const filePath = tempfile();546 const stdoutOption = [generatorsMap[type].uppercaseBuffer(false, true), {file: filePath}];547 const reversedStdoutOption = reversed ? stdoutOption.reverse() : stdoutOption;496- const {stdout} = await execa('noop-fd.js', ['1'], {stdout: reversedStdoutOption});548+ const {stdout} = await execaMethod('noop-fd.js', ['1'], {stdout: reversedStdoutOption});549 t.is(stdout, foobarUppercase);550 t.is(await readFile(filePath, 'utf8'), foobarUppercase);551 await rm(filePath);552 };553 502-test('Can use generators with a file as output', testOutputFile, false, 'generator');503-test('Can use generators with a file as output, reversed', testOutputFile, true, 'generator');504-test('Can use duplexes with a file as output', testOutputFile, false, 'duplex');505-test('Can use duplexes with a file as output, reversed', testOutputFile, true, 'duplex');506-test('Can use webTransforms with a file as output', testOutputFile, false, 'webTransform');507-test('Can use webTransforms with a file as output, reversed', testOutputFile, true, 'webTransform');554+test('Can use generators with a file as output', testOutputFile, false, 'generator', execa);555+test('Can use generators with a file as output, reversed', testOutputFile, true, 'generator', execa);556+test('Can use generators with a file as output, sync', testOutputFile, false, 'generator', execaSync);557+test('Can use generators with a file as output, reversed, sync', testOutputFile, true, 'generator', execaSync);558+test('Can use duplexes with a file as output', testOutputFile, false, 'duplex', execa);559+test('Can use duplexes with a file as output, reversed', testOutputFile, true, 'duplex', execa);560+test('Can use webTransforms with a file as output', testOutputFile, false, 'webTransform', execa);561+test('Can use webTransforms with a file as output, reversed', testOutputFile, true, 'webTransform', execa);562 563 const testWritableDestination = async (t, type) => {564 const passThrough = new PassThrough();565 const [{stdout}, streamOutput] = await Promise.all([28 unmodified lines594 test('Can use generators with "inherit"', testInherit, 'generator');595 test('Can use duplexes with "inherit"', testInherit, 'duplex');596 test('Can use webTransforms with "inherit"', testInherit, 'webTransform');597 544-const testAppendInput = async (t, reversed, type) => {598+const testAppendInput = async (t, reversed, type, execaMethod) => {599 const stdin = [foobarUint8Array, generatorsMap[type].uppercase(), generatorsMap[type].append()];600 const reversedStdin = reversed ? stdin.reverse() : stdin;547- const {stdout} = await execa('stdin-fd.js', ['0'], {stdin: reversedStdin});601+ const {stdout} = await execaMethod('stdin-fd.js', ['0'], {stdin: reversedStdin});602 const reversedSuffix = reversed ? casedSuffix.toUpperCase() : casedSuffix;603 t.is(stdout, `${foobarUppercase}${reversedSuffix}`);604 };605 552-test('Can use multiple generators as input', testAppendInput, false, 'generator');553-test('Can use multiple generators as input, reversed', testAppendInput, true, 'generator');554-test('Can use multiple duplexes as input', testAppendInput, false, 'duplex');555-test('Can use multiple duplexes as input, reversed', testAppendInput, true, 'duplex');556-test('Can use multiple webTransforms as input', testAppendInput, false, 'webTransform');557-test('Can use multiple webTransforms as input, reversed', testAppendInput, true, 'webTransform');606+test('Can use multiple generators as input', testAppendInput, false, 'generator', execa);607+test('Can use multiple generators as input, reversed', testAppendInput, true, 'generator', execa);608+test('Can use multiple generators as input, sync', testAppendInput, false, 'generator', execaSync);609+test('Can use multiple generators as input, reversed, sync', testAppendInput, true, 'generator', execaSync);610+test('Can use multiple duplexes as input', testAppendInput, false, 'duplex', execa);611+test('Can use multiple duplexes as input, reversed', testAppendInput, true, 'duplex', execa);612+test('Can use multiple webTransforms as input', testAppendInput, false, 'webTransform', execa);613+test('Can use multiple webTransforms as input, reversed', testAppendInput, true, 'webTransform', execa);614 559-const testAppendOutput = async (t, reversed, type) => {615+const testAppendOutput = async (t, reversed, type, execaMethod) => {616 const stdoutOption = [generatorsMap[type].uppercase(), generatorsMap[type].append()];617 const reversedStdoutOption = reversed ? stdoutOption.reverse() : stdoutOption;562- const {stdout} = await execa('noop-fd.js', ['1', foobarString], {stdout: reversedStdoutOption});618+ const {stdout} = await execaMethod('noop-fd.js', ['1', foobarString], {stdout: reversedStdoutOption});619 const reversedSuffix = reversed ? casedSuffix.toUpperCase() : casedSuffix;620 t.is(stdout, `${foobarUppercase}${reversedSuffix}`);621 };622 567-test('Can use multiple generators as output', testAppendOutput, false, 'generator');568-test('Can use multiple generators as output, reversed', testAppendOutput, true, 'generator');569-test('Can use multiple duplexes as output', testAppendOutput, false, 'duplex');570-test('Can use multiple duplexes as output, reversed', testAppendOutput, true, 'duplex');571-test('Can use multiple webTransforms as output', testAppendOutput, false, 'webTransform');572-test('Can use multiple webTransforms as output, reversed', testAppendOutput, true, 'webTransform');623+test('Can use multiple generators as output', testAppendOutput, false, 'generator', execa);624+test('Can use multiple generators as output, reversed', testAppendOutput, true, 'generator', execa);625+test('Can use multiple generators as output, sync', testAppendOutput, false, 'generator', execaSync);626+test('Can use multiple generators as output, reversed, sync', testAppendOutput, true, 'generator', execaSync);627+test('Can use multiple duplexes as output', testAppendOutput, false, 'duplex', execa);628+test('Can use multiple duplexes as output, reversed', testAppendOutput, true, 'duplex', execa);629+test('Can use multiple webTransforms as output', testAppendOutput, false, 'webTransform', execa);630+test('Can use multiple webTransforms as output, reversed', testAppendOutput, true, 'webTransform', execa);631 632+// eslint-disable-next-line max-params574-const testTwoGenerators = async (t, producesTwo, firstGenerator, secondGenerator = firstGenerator) => {575- const {stdout} = await execa('noop-fd.js', ['1', foobarString], {stdout: [firstGenerator, secondGenerator]});633+const testTwoGenerators = async (t, producesTwo, execaMethod, firstGenerator, secondGenerator = firstGenerator) => {634+ const {stdout} = await execaMethod('noop-fd.js', ['1', foobarString], {stdout: [firstGenerator, secondGenerator]});635 const expectedSuffix = producesTwo ? `${casedSuffix}${casedSuffix}` : casedSuffix;636 t.is(stdout, `${foobarString}${expectedSuffix}`);637 };638 639+test('Can use multiple identical generators', testTwoGenerators, true, execa, appendGenerator().transform);640+test('Can use multiple identical generators, options object', testTwoGenerators, true, execa, appendGenerator());641+test('Can use multiple identical generators, async', testTwoGenerators, true, execa, appendAsyncGenerator().transform);642+test('Can use multiple identical generators, options object, async', testTwoGenerators, true, execa, appendAsyncGenerator());580-test('Can use multiple identical generators', testTwoGenerators, true, appendGenerator().transform);581-test('Can use multiple identical generators, options object', testTwoGenerators, true, appendGenerator());582-test('Ignore duplicate identical duplexes', testTwoGenerators, false, appendDuplex());583-test('Ignore duplicate identical webTransforms', testTwoGenerators, false, appendWebTransform());584-test('Can use multiple generators with duplexes', testTwoGenerators, true, appendGenerator(false, false, true), appendDuplex());585-test('Can use multiple generators with webTransforms', testTwoGenerators, true, appendGenerator(false, false, true), appendWebTransform());586-test('Can use multiple duplexes with webTransforms', testTwoGenerators, true, appendDuplex(), appendWebTransform());643+test('Can use multiple identical generators, sync', testTwoGenerators, true, execaSync, appendGenerator().transform);644+test('Can use multiple identical generators, options object, sync', testTwoGenerators, true, execaSync, appendGenerator());645+test('Ignore duplicate identical duplexes', testTwoGenerators, false, execa, appendDuplex());646+test('Ignore duplicate identical webTransforms', testTwoGenerators, false, execa, appendWebTransform());647+test('Can use multiple generators with duplexes', testTwoGenerators, true, execa, appendGenerator(false, false, true), appendDuplex());648+test('Can use multiple generators with webTransforms', testTwoGenerators, true, execa, appendGenerator(false, false, true), appendWebTransform());649+test('Can use multiple duplexes with webTransforms', testTwoGenerators, true, execa, appendDuplex(), appendWebTransform());650 588-const testGeneratorSyntax = async (t, type, usePlainObject) => {651+const testGeneratorSyntax = async (t, type, usePlainObject, execaMethod) => {652 const transform = generatorsMap[type].uppercase();590- const {stdout} = await execa('noop-fd.js', ['1', foobarString], {stdout: usePlainObject ? transform : transform.transform});653+ const {stdout} = await execaMethod('noop-fd.js', ['1', foobarString], {stdout: usePlainObject ? transform : transform.transform});654 t.is(stdout, foobarUppercase);655 };656 594-test('Can pass generators with an options plain object', testGeneratorSyntax, 'generator', false);595-test('Can pass generators without an options plain object', testGeneratorSyntax, 'generator', true);596-test('Can pass webTransforms with an options plain object', testGeneratorSyntax, 'webTransform', true);597-test('Can pass webTransforms without an options plain object', testGeneratorSyntax, 'webTransform', false);657+test('Can pass generators with an options plain object', testGeneratorSyntax, 'generator', false, execa);658+test('Can pass generators without an options plain object', testGeneratorSyntax, 'generator', true, execa);659+test('Can pass generators with an options plain object, sync', testGeneratorSyntax, 'generator', false, execaSync);660+test('Can pass generators without an options plain object, sync', testGeneratorSyntax, 'generator', true, execaSync);661+test('Can pass webTransforms with an options plain object', testGeneratorSyntax, 'webTransform', true, execa);662+test('Can pass webTransforms without an options plain object', testGeneratorSyntax, 'webTransform', false, execa);added:test/stdio/input-sync.js+18 added
1+import test from 'ava';2+import {execaSync} from '../../index.js';3+import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {getStdio} from '../helpers/stdio.js';5+6+setFixtureDir();7+8+const getFd3InputMessage = type => `not \`stdio[3]\`, can be ${type}`;9+10+const testFd3InputSync = (t, stdioOption, expectedMessage) => {11+ const {message} = t.throws(() => {12+ execaSync('empty.js', getStdio(3, stdioOption));13+ });14+ t.true(message.includes(expectedMessage));15+};16+17+test('Cannot use Uint8Array with stdio[*], sync', testFd3InputSync, new Uint8Array(), getFd3InputMessage('a Uint8Array'));18+test('Cannot use iterable with stdio[*], sync', testFd3InputSync, [[]], getFd3InputMessage('an iterable'));modified:test/stdio/iterable.js+44 added-30 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, foobarArray} from '../helpers/input.js';8-import {serializeGenerator, infiniteGenerator, throwingGenerator} from '../helpers/generator.js';7+import {foobarString, foobarObject, foobarObjectString, foobarArray} from '../helpers/input.js';8+import {noopGenerator, serializeGenerator, infiniteGenerator, throwingGenerator} from '../helpers/generator.js';9 10 const stringGenerator = function * () {11 yield * foobarArray;12 };50 unmodified lines63 const foobarAsyncObjectGenerator = async function * () {64 yield foobarObject;65 };66 67-const testObjectIterable = async (t, stdioOption, fdNumber) => {68- const {stdout} = await execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stdioOption, serializeGenerator(true)]));67+const testObjectIterable = async (t, stdioOption, fdNumber, execaMethod) => {68+ const {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stdioOption, serializeGenerator(true)]));69 t.is(stdout, foobarObjectString);70 };71 72-test('stdin option can be an array of objects', testObjectIterable, [foobarObject], 0);73-test('stdio[*] option can be an array of objects', testObjectIterable, [foobarObject], 3);74-test('stdin option can be an iterable of objects', testObjectIterable, foobarObjectGenerator(), 0);75-test('stdio[*] option can be an iterable of objects', testObjectIterable, foobarObjectGenerator(), 3);76-test('stdin option can be an async iterable of objects', testObjectIterable, foobarAsyncObjectGenerator(), 0);77-test('stdio[*] option can be an async iterable of objects', testObjectIterable, foobarAsyncObjectGenerator(), 3);72+test('stdin option can be an array of objects', testObjectIterable, [foobarObject], 0, execa);73+test('stdio[*] option can be an array of objects', testObjectIterable, [foobarObject], 3, execa);74+test('stdin option can be an iterable of objects', testObjectIterable, foobarObjectGenerator(), 0, execa);75+test('stdio[*] option can be an iterable of objects', testObjectIterable, foobarObjectGenerator(), 3, execa);76+test('stdin option can be an async iterable of objects', testObjectIterable, foobarAsyncObjectGenerator(), 0, execa);77+test('stdio[*] option can be an async iterable of objects', testObjectIterable, foobarAsyncObjectGenerator(), 3, execa);78+test('stdin option can be an array of objects - sync', testObjectIterable, [foobarObject], 0, execaSync);79+test('stdin option can be an iterable of objects - sync', testObjectIterable, foobarObjectGenerator(), 0, execaSync);80 81+const testIterableNoGeneratorsSync = (t, stdioOption, fdNumber) => {82+ t.throws(() => {83+ execaSync('empty.js', getStdio(fdNumber, stdioOption));84+ }, {message: /must be used to serialize/});85+};86+87+test('stdin option cannot be an array of objects without generators - sync', testIterableNoGeneratorsSync, [[foobarObject]], 0);88+test('stdin option cannot be an iterable of objects without generators - sync', testIterableNoGeneratorsSync, foobarObjectGenerator(), 0);89+90+const testIterableNoSerializeSync = (t, stdioOption, fdNumber) => {91+ t.throws(() => {92+ execaSync('empty.js', getStdio(fdNumber, [stdioOption, noopGenerator()]));93+ }, {message: /The `stdin` option's transform must use "objectMode: true" to receive as input: object/});94+};95+96+test('stdin option cannot be an array of objects without serializing - sync', testIterableNoSerializeSync, [foobarObject], 0);97+test('stdin option cannot be an iterable of objects without serializing - sync', testIterableNoSerializeSync, foobarObjectGenerator(), 0);98+99 const testIterableSync = (t, stdioOption, fdNumber) => {100 t.throws(() => {101 execaSync('empty.js', getStdio(fdNumber, stdioOption));102 }, {message: /an iterable with synchronous methods/});6 unmodified lines109 test('stdio[*] option cannot be an iterable of Uint8Arrays - sync', testIterableSync, binaryGenerator(), 3);110 test('stdio[*] option cannot be an iterable of objects - sync', testIterableSync, foobarObjectGenerator(), 3);111 test('stdio[*] option cannot be multiple iterables - sync', testIterableSync, [stringGenerator(), stringGenerator()], 3);112 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-113 const testAsyncIterableSync = (t, stdioOption, fdNumber) => {114 t.throws(() => {115 execaSync('empty.js', getStdio(fdNumber, stdioOption));116 }, {message: /an async iterable with synchronous method/});3 unmodified lines120 test('stdio[*] option cannot be an async iterable - sync', testAsyncIterableSync, asyncGenerator(), 3);121 test('stdin option cannot be an async iterable of objects - sync', testAsyncIterableSync, foobarAsyncObjectGenerator(), 0);122 test('stdio[*] option cannot be an async iterable of objects - sync', testAsyncIterableSync, foobarAsyncObjectGenerator(), 3);123 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');124+const testIterableError = async (t, fdNumber) => {125+ const cause = new Error(foobarString);126+ const error = await t.throwsAsync(execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, throwingGenerator(cause)().transform())));127+ t.is(error.cause, cause);128 };129 118-test('stdin option handles errors in iterables', testIterableError, 0, execa);119-test('stdio[*] option handles errors in iterables', testIterableError, 3, execa);130+test('stdin option handles errors in iterables', testIterableError, 0);131+test('stdio[*] option handles errors in iterables', testIterableError, 3);132 121-const testIterableErrorSync = (t, fdNumber, execaMethod) => {122- t.throws(() => {123- execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, throwingGenerator().transform()));124- }, {message: 'Generator error'});133+const testIterableErrorSync = (t, fdNumber) => {134+ const cause = new Error(foobarString);135+ const error = t.throws(() => {136+ execaSync('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, throwingGenerator(cause)().transform()));137+ });138+ t.is(error, cause);139 };140 127-test('stdin option handles errors in iterables - sync', testIterableErrorSync, 0, execaSync);128-test('stdio[*] option handles errors in iterables - sync', testIterableErrorSync, 3, execaSync);141+test('stdin option handles errors in iterables - sync', testIterableErrorSync, 0);142+test('stdio[*] option handles errors in iterables - sync', testIterableErrorSync, 3);143 144 const testNoIterableOutput = (t, stdioOption, fdNumber, execaMethod) => {145 t.throws(() => {146 execaMethod('empty.js', getStdio(fdNumber, stdioOption));46 unmodified linesadded:test/stdio/output-sync.js+33 added
1+import test from 'ava';2+import {execaSync} from '../../index.js';3+import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {throwingGenerator} from '../helpers/generator.js';5+import {foobarString} from '../helpers/input.js';6+7+setFixtureDir();8+9+test('Handles errors with stdout generator, sync', t => {10+ const cause = new Error(foobarString);11+ const error = t.throws(() => {12+ execaSync('noop.js', {stdout: throwingGenerator(cause)()});13+ });14+ t.is(error.cause, cause);15+});16+17+test('Handles errors with stdout generator, spawn failure, sync', t => {18+ const cause = new Error(foobarString);19+ const error = t.throws(() => {20+ execaSync('noop.js', {cwd: 'does_not_exist', stdout: throwingGenerator(cause)()});21+ });22+ t.true(error.failed);23+ t.is(error.cause.code, 'ENOENT');24+});25+26+test('Handles errors with stdout generator, subprocess failure, sync', t => {27+ const cause = new Error(foobarString);28+ const error = t.throws(() => {29+ execaSync('noop-fail.js', ['1'], {stdout: throwingGenerator(cause)()});30+ });31+ t.true(error.failed);32+ t.is(error.cause, cause);33+});modified:test/stdio/split.js+183 added-98 removed
1 import test from 'ava';2-import {execa} from '../../index.js';2+import {execa, execaSync} from '../../index.js';3 import {setFixtureDir} from '../helpers/fixtures-dir.js';4 import {getStdio} from '../helpers/stdio.js';5 import {6 getOutputsGenerator,50 unmodified lines57 const manyLines = [manyFull];58 const mixedNewlines = '.\n.\r\n.\n.\r\n.\n';59 60 // eslint-disable-next-line max-params61-const testLines = async (t, fdNumber, input, expectedLines, expectedOutput, objectMode, preserveNewlines) => {61+const testLines = async (t, fdNumber, input, expectedLines, expectedOutput, objectMode, preserveNewlines, execaMethod) => {62 const lines = [];63- const {stdio} = await execa('noop-fd.js', [`${fdNumber}`], {63+ const {stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`], {64 ...getStdio(fdNumber, [65 getOutputsGenerator(input)(false, true),66 resultGenerator(lines)(objectMode, false, preserveNewlines),67 ]),2 unmodified lines70 t.deepEqual(lines, expectedLines);71 t.deepEqual(stdio[fdNumber], expectedOutput);72 };73 74-test('Split stdout - n newlines, 1 chunk', testLines, 1, simpleChunks, simpleLines, simpleFull, false, true);75-test('Split stderr - n newlines, 1 chunk', testLines, 2, simpleChunks, simpleLines, simpleFull, false, true);76-test('Split stdio[*] - n newlines, 1 chunk', testLines, 3, simpleChunks, simpleLines, simpleFull, false, true);77-test('Split stdout - preserveNewlines, n chunks', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesFull, false, true);78-test('Split stdout - 0 newlines, 1 chunk', testLines, 1, singleChunks, singleChunks, singleFull, false, true);79-test('Split stdout - empty, 1 chunk', testLines, 1, emptyChunks, noLines, emptyFull, false, true);80-test('Split stdout - Windows newlines', testLines, 1, windowsChunks, windowsLines, windowsFull, false, true);81-test('Split stdout - chunk ends with newline', testLines, 1, simpleFullEndChunks, simpleFullEndLines, simpleFullEnd, false, true);82-test('Split stdout - single newline', testLines, 1, newlineChunks, newlineChunks, newlineFull, false, true);83-test('Split stdout - only newlines', testLines, 1, newlinesChunks, newlinesLines, newlinesFull, false, true);84-test('Split stdout - only Windows newlines', testLines, 1, windowsNewlinesChunks, windowsNewlinesLines, windowsNewlinesFull, false, true);85-test('Split stdout - line split over multiple chunks', testLines, 1, runOverChunks, simpleLines, simpleFull, false, true);86-test('Split stdout - 0 newlines, big line', testLines, 1, bigChunks, bigChunks, bigFull, false, true);87-test('Split stdout - 0 newlines, many chunks', testLines, 1, manyChunks, manyLines, manyFull, false, true);88-test('Split stdout - n newlines, 1 chunk, objectMode', testLines, 1, simpleChunks, simpleLines, simpleLines, true, true);89-test('Split stderr - n newlines, 1 chunk, objectMode', testLines, 2, simpleChunks, simpleLines, simpleLines, true, true);90-test('Split stdio[*] - n newlines, 1 chunk, objectMode', testLines, 3, simpleChunks, simpleLines, simpleLines, true, true);91-test('Split stdout - preserveNewlines, n chunks, objectMode', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesLines, true, true);92-test('Split stdout - empty, 1 chunk, objectMode', testLines, 1, emptyChunks, noLines, noLines, true, true);93-test('Split stdout - 0 newlines, 1 chunk, objectMode', testLines, 1, singleChunks, singleChunks, singleChunks, true, true);94-test('Split stdout - Windows newlines, objectMode', testLines, 1, windowsChunks, windowsLines, windowsLines, true, true);95-test('Split stdout - chunk ends with newline, objectMode', testLines, 1, simpleFullEndChunks, simpleFullEndLines, simpleFullEndLines, true, true);96-test('Split stdout - single newline, objectMode', testLines, 1, newlineChunks, newlineChunks, newlineChunks, true, true);97-test('Split stdout - only newlines, objectMode', testLines, 1, newlinesChunks, newlinesLines, newlinesLines, true, true);98-test('Split stdout - only Windows newlines, objectMode', testLines, 1, windowsNewlinesChunks, windowsNewlinesLines, windowsNewlinesLines, true, true);99-test('Split stdout - line split over multiple chunks, objectMode', testLines, 1, runOverChunks, simpleLines, simpleLines, true, true);100-test('Split stdout - 0 newlines, big line, objectMode', testLines, 1, bigChunks, bigChunks, bigChunks, true, true);101-test('Split stdout - 0 newlines, many chunks, objectMode', testLines, 1, manyChunks, manyLines, manyLines, true, true);102-test('Split stdout - n newlines, 1 chunk, preserveNewlines', testLines, 1, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false);103-test('Split stderr - n newlines, 1 chunk, preserveNewlines', testLines, 2, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false);104-test('Split stdio[*] - n newlines, 1 chunk, preserveNewlines', testLines, 3, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false);105-test('Split stdout - preserveNewlines, n chunks, preserveNewlines', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesFullEnd, false, false);106-test('Split stdout - empty, 1 chunk, preserveNewlines', testLines, 1, emptyChunks, noLines, emptyFull, false, false);107-test('Split stdout - 0 newlines, 1 chunk, preserveNewlines', testLines, 1, singleChunks, singleChunks, singleFullEnd, false, false);108-test('Split stdout - Windows newlines, preserveNewlines', testLines, 1, windowsChunks, noNewlinesChunks, windowsFullEnd, false, false);109-test('Split stdout - chunk ends with newline, preserveNewlines', testLines, 1, simpleFullEndChunks, noNewlinesChunks, simpleFullEnd, false, false);110-test('Split stdout - single newline, preserveNewlines', testLines, 1, newlineChunks, emptyChunks, newlineFull, false, false);111-test('Split stdout - only newlines, preserveNewlines', testLines, 1, newlinesChunks, manyEmptyChunks, newlinesFull, false, false);112-test('Split stdout - only Windows newlines, preserveNewlines', testLines, 1, windowsNewlinesChunks, manyEmptyChunks, windowsNewlinesFull, false, false);113-test('Split stdout - line split over multiple chunks, preserveNewlines', testLines, 1, runOverChunks, noNewlinesChunks, simpleFullEnd, false, false);114-test('Split stdout - 0 newlines, big line, preserveNewlines', testLines, 1, bigChunks, bigChunks, bigFullEnd, false, false);115-test('Split stdout - 0 newlines, many chunks, preserveNewlines', testLines, 1, manyChunks, manyLines, manyFullEnd, false, false);116-test('Split stdout - n newlines, 1 chunk, objectMode, preserveNewlines', testLines, 1, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false);117-test('Split stderr - n newlines, 1 chunk, objectMode, preserveNewlines', testLines, 2, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false);118-test('Split stdio[*] - n newlines, 1 chunk, objectMode, preserveNewlines', testLines, 3, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false);119-test('Split stdout - preserveNewlines, n chunks, objectMode, preserveNewlines', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesLines, true, false);120-test('Split stdout - empty, 1 chunk, objectMode, preserveNewlines', testLines, 1, emptyChunks, noLines, noLines, true, false);121-test('Split stdout - 0 newlines, 1 chunk, objectMode, preserveNewlines', testLines, 1, singleChunks, singleChunks, singleChunks, true, false);122-test('Split stdout - Windows newlines, objectMode, preserveNewlines', testLines, 1, windowsChunks, noNewlinesChunks, noNewlinesChunks, true, false);123-test('Split stdout - chunk ends with newline, objectMode, preserveNewlines', testLines, 1, simpleFullEndChunks, noNewlinesChunks, noNewlinesChunks, true, false);124-test('Split stdout - single newline, objectMode, preserveNewlines', testLines, 1, newlineChunks, emptyChunks, emptyChunks, true, false);125-test('Split stdout - only newlines, objectMode, preserveNewlines', testLines, 1, newlinesChunks, manyEmptyChunks, manyEmptyChunks, true, false);126-test('Split stdout - only Windows newlines, objectMode, preserveNewlines', testLines, 1, windowsNewlinesChunks, manyEmptyChunks, manyEmptyChunks, true, false);127-test('Split stdout - line split over multiple chunks, objectMode, preserveNewlines', testLines, 1, runOverChunks, noNewlinesChunks, noNewlinesChunks, true, false);128-test('Split stdout - 0 newlines, big line, objectMode, preserveNewlines', testLines, 1, bigChunks, bigChunks, bigChunks, true, false);129-test('Split stdout - 0 newlines, many chunks, objectMode, preserveNewlines', testLines, 1, manyChunks, manyLines, manyLines, true, false);74+test('Split stdout - n newlines, 1 chunk', testLines, 1, simpleChunks, simpleLines, simpleFull, false, true, execa);75+test('Split stderr - n newlines, 1 chunk', testLines, 2, simpleChunks, simpleLines, simpleFull, false, true, execa);76+test('Split stdio[*] - n newlines, 1 chunk', testLines, 3, simpleChunks, simpleLines, simpleFull, false, true, execa);77+test('Split stdout - preserveNewlines, n chunks', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesFull, false, true, execa);78+test('Split stdout - 0 newlines, 1 chunk', testLines, 1, singleChunks, singleChunks, singleFull, false, true, execa);79+test('Split stdout - empty, 1 chunk', testLines, 1, emptyChunks, noLines, emptyFull, false, true, execa);80+test('Split stdout - Windows newlines', testLines, 1, windowsChunks, windowsLines, windowsFull, false, true, execa);81+test('Split stdout - chunk ends with newline', testLines, 1, simpleFullEndChunks, simpleFullEndLines, simpleFullEnd, false, true, execa);82+test('Split stdout - single newline', testLines, 1, newlineChunks, newlineChunks, newlineFull, false, true, execa);83+test('Split stdout - only newlines', testLines, 1, newlinesChunks, newlinesLines, newlinesFull, false, true, execa);84+test('Split stdout - only Windows newlines', testLines, 1, windowsNewlinesChunks, windowsNewlinesLines, windowsNewlinesFull, false, true, execa);85+test('Split stdout - line split over multiple chunks', testLines, 1, runOverChunks, simpleLines, simpleFull, false, true, execa);86+test('Split stdout - 0 newlines, big line', testLines, 1, bigChunks, bigChunks, bigFull, false, true, execa);87+test('Split stdout - 0 newlines, many chunks', testLines, 1, manyChunks, manyLines, manyFull, false, true, execa);88+test('Split stdout - n newlines, 1 chunk, objectMode', testLines, 1, simpleChunks, simpleLines, simpleLines, true, true, execa);89+test('Split stderr - n newlines, 1 chunk, objectMode', testLines, 2, simpleChunks, simpleLines, simpleLines, true, true, execa);90+test('Split stdio[*] - n newlines, 1 chunk, objectMode', testLines, 3, simpleChunks, simpleLines, simpleLines, true, true, execa);91+test('Split stdout - preserveNewlines, n chunks, objectMode', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesLines, true, true, execa);92+test('Split stdout - empty, 1 chunk, objectMode', testLines, 1, emptyChunks, noLines, noLines, true, true, execa);93+test('Split stdout - 0 newlines, 1 chunk, objectMode', testLines, 1, singleChunks, singleChunks, singleChunks, true, true, execa);94+test('Split stdout - Windows newlines, objectMode', testLines, 1, windowsChunks, windowsLines, windowsLines, true, true, execa);95+test('Split stdout - chunk ends with newline, objectMode', testLines, 1, simpleFullEndChunks, simpleFullEndLines, simpleFullEndLines, true, true, execa);96+test('Split stdout - single newline, objectMode', testLines, 1, newlineChunks, newlineChunks, newlineChunks, true, true, execa);97+test('Split stdout - only newlines, objectMode', testLines, 1, newlinesChunks, newlinesLines, newlinesLines, true, true, execa);98+test('Split stdout - only Windows newlines, objectMode', testLines, 1, windowsNewlinesChunks, windowsNewlinesLines, windowsNewlinesLines, true, true, execa);99+test('Split stdout - line split over multiple chunks, objectMode', testLines, 1, runOverChunks, simpleLines, simpleLines, true, true, execa);100+test('Split stdout - 0 newlines, big line, objectMode', testLines, 1, bigChunks, bigChunks, bigChunks, true, true, execa);101+test('Split stdout - 0 newlines, many chunks, objectMode', testLines, 1, manyChunks, manyLines, manyLines, true, true, execa);102+test('Split stdout - n newlines, 1 chunk, preserveNewlines', testLines, 1, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execa);103+test('Split stderr - n newlines, 1 chunk, preserveNewlines', testLines, 2, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execa);104+test('Split stdio[*] - n newlines, 1 chunk, preserveNewlines', testLines, 3, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execa);105+test('Split stdout - preserveNewlines, n chunks, preserveNewlines', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesFullEnd, false, false, execa);106+test('Split stdout - empty, 1 chunk, preserveNewlines', testLines, 1, emptyChunks, noLines, emptyFull, false, false, execa);107+test('Split stdout - 0 newlines, 1 chunk, preserveNewlines', testLines, 1, singleChunks, singleChunks, singleFullEnd, false, false, execa);108+test('Split stdout - Windows newlines, preserveNewlines', testLines, 1, windowsChunks, noNewlinesChunks, windowsFullEnd, false, false, execa);109+test('Split stdout - chunk ends with newline, preserveNewlines', testLines, 1, simpleFullEndChunks, noNewlinesChunks, simpleFullEnd, false, false, execa);110+test('Split stdout - single newline, preserveNewlines', testLines, 1, newlineChunks, emptyChunks, newlineFull, false, false, execa);111+test('Split stdout - only newlines, preserveNewlines', testLines, 1, newlinesChunks, manyEmptyChunks, newlinesFull, false, false, execa);112+test('Split stdout - only Windows newlines, preserveNewlines', testLines, 1, windowsNewlinesChunks, manyEmptyChunks, windowsNewlinesFull, false, false, execa);113+test('Split stdout - line split over multiple chunks, preserveNewlines', testLines, 1, runOverChunks, noNewlinesChunks, simpleFullEnd, false, false, execa);114+test('Split stdout - 0 newlines, big line, preserveNewlines', testLines, 1, bigChunks, bigChunks, bigFullEnd, false, false, execa);115+test('Split stdout - 0 newlines, many chunks, preserveNewlines', testLines, 1, manyChunks, manyLines, manyFullEnd, false, false, execa);116+test('Split stdout - n newlines, 1 chunk, objectMode, preserveNewlines', testLines, 1, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);117+test('Split stderr - n newlines, 1 chunk, objectMode, preserveNewlines', testLines, 2, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);118+test('Split stdio[*] - n newlines, 1 chunk, objectMode, preserveNewlines', testLines, 3, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);119+test('Split stdout - preserveNewlines, n chunks, objectMode, preserveNewlines', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesLines, true, false, execa);120+test('Split stdout - empty, 1 chunk, objectMode, preserveNewlines', testLines, 1, emptyChunks, noLines, noLines, true, false, execa);121+test('Split stdout - 0 newlines, 1 chunk, objectMode, preserveNewlines', testLines, 1, singleChunks, singleChunks, singleChunks, true, false, execa);122+test('Split stdout - Windows newlines, objectMode, preserveNewlines', testLines, 1, windowsChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);123+test('Split stdout - chunk ends with newline, objectMode, preserveNewlines', testLines, 1, simpleFullEndChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);124+test('Split stdout - single newline, objectMode, preserveNewlines', testLines, 1, newlineChunks, emptyChunks, emptyChunks, true, false, execa);125+test('Split stdout - only newlines, objectMode, preserveNewlines', testLines, 1, newlinesChunks, manyEmptyChunks, manyEmptyChunks, true, false, execa);126+test('Split stdout - only Windows newlines, objectMode, preserveNewlines', testLines, 1, windowsNewlinesChunks, manyEmptyChunks, manyEmptyChunks, true, false, execa);127+test('Split stdout - line split over multiple chunks, objectMode, preserveNewlines', testLines, 1, runOverChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);128+test('Split stdout - 0 newlines, big line, objectMode, preserveNewlines', testLines, 1, bigChunks, bigChunks, bigChunks, true, false, execa);129+test('Split stdout - 0 newlines, many chunks, objectMode, preserveNewlines', testLines, 1, manyChunks, manyLines, manyLines, true, false, execa);130+test('Split stdout - n newlines, 1 chunk, sync', testLines, 1, simpleChunks, simpleLines, simpleFull, false, true, execaSync);131+test('Split stderr - n newlines, 1 chunk, sync', testLines, 2, simpleChunks, simpleLines, simpleFull, false, true, execaSync);132+test('Split stdio[*] - n newlines, 1 chunk, sync', testLines, 3, simpleChunks, simpleLines, simpleFull, false, true, execaSync);133+test('Split stdout - preserveNewlines, n chunks, sync', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesFull, false, true, execaSync);134+test('Split stdout - 0 newlines, 1 chunk, sync', testLines, 1, singleChunks, singleChunks, singleFull, false, true, execaSync);135+test('Split stdout - empty, 1 chunk, sync', testLines, 1, emptyChunks, noLines, emptyFull, false, true, execaSync);136+test('Split stdout - Windows newlines, sync', testLines, 1, windowsChunks, windowsLines, windowsFull, false, true, execaSync);137+test('Split stdout - chunk ends with newline, sync', testLines, 1, simpleFullEndChunks, simpleFullEndLines, simpleFullEnd, false, true, execaSync);138+test('Split stdout - single newline, sync', testLines, 1, newlineChunks, newlineChunks, newlineFull, false, true, execaSync);139+test('Split stdout - only newlines, sync', testLines, 1, newlinesChunks, newlinesLines, newlinesFull, false, true, execaSync);140+test('Split stdout - only Windows newlines, sync', testLines, 1, windowsNewlinesChunks, windowsNewlinesLines, windowsNewlinesFull, false, true, execaSync);141+test('Split stdout - line split over multiple chunks, sync', testLines, 1, runOverChunks, simpleLines, simpleFull, false, true, execaSync);142+test('Split stdout - 0 newlines, big line, sync', testLines, 1, bigChunks, bigChunks, bigFull, false, true, execaSync);143+test('Split stdout - 0 newlines, many chunks, sync', testLines, 1, manyChunks, manyLines, manyFull, false, true, execaSync);144+test('Split stdout - n newlines, 1 chunk, objectMode, sync', testLines, 1, simpleChunks, simpleLines, simpleLines, true, true, execaSync);145+test('Split stderr - n newlines, 1 chunk, objectMode, sync', testLines, 2, simpleChunks, simpleLines, simpleLines, true, true, execaSync);146+test('Split stdio[*] - n newlines, 1 chunk, objectMode, sync', testLines, 3, simpleChunks, simpleLines, simpleLines, true, true, execaSync);147+test('Split stdout - preserveNewlines, n chunks, objectMode, sync', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesLines, true, true, execaSync);148+test('Split stdout - empty, 1 chunk, objectMode, sync', testLines, 1, emptyChunks, noLines, noLines, true, true, execaSync);149+test('Split stdout - 0 newlines, 1 chunk, objectMode, sync', testLines, 1, singleChunks, singleChunks, singleChunks, true, true, execaSync);150+test('Split stdout - Windows newlines, objectMode, sync', testLines, 1, windowsChunks, windowsLines, windowsLines, true, true, execaSync);151+test('Split stdout - chunk ends with newline, objectMode, sync', testLines, 1, simpleFullEndChunks, simpleFullEndLines, simpleFullEndLines, true, true, execaSync);152+test('Split stdout - single newline, objectMode, sync', testLines, 1, newlineChunks, newlineChunks, newlineChunks, true, true, execaSync);153+test('Split stdout - only newlines, objectMode, sync', testLines, 1, newlinesChunks, newlinesLines, newlinesLines, true, true, execaSync);154+test('Split stdout - only Windows newlines, objectMode, sync', testLines, 1, windowsNewlinesChunks, windowsNewlinesLines, windowsNewlinesLines, true, true, execaSync);155+test('Split stdout - line split over multiple chunks, objectMode, sync', testLines, 1, runOverChunks, simpleLines, simpleLines, true, true, execaSync);156+test('Split stdout - 0 newlines, big line, objectMode, sync', testLines, 1, bigChunks, bigChunks, bigChunks, true, true, execaSync);157+test('Split stdout - 0 newlines, many chunks, objectMode, sync', testLines, 1, manyChunks, manyLines, manyLines, true, true, execaSync);158+test('Split stdout - n newlines, 1 chunk, preserveNewlines, sync', testLines, 1, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execaSync);159+test('Split stderr - n newlines, 1 chunk, preserveNewlines, sync', testLines, 2, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execaSync);160+test('Split stdio[*] - n newlines, 1 chunk, preserveNewlines, sync', testLines, 3, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execaSync);161+test('Split stdout - preserveNewlines, n chunks, preserveNewlines, sync', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesFullEnd, false, false, execaSync);162+test('Split stdout - empty, 1 chunk, preserveNewlines, sync', testLines, 1, emptyChunks, noLines, emptyFull, false, false, execaSync);163+test('Split stdout - 0 newlines, 1 chunk, preserveNewlines, sync', testLines, 1, singleChunks, singleChunks, singleFullEnd, false, false, execaSync);164+test('Split stdout - Windows newlines, preserveNewlines, sync', testLines, 1, windowsChunks, noNewlinesChunks, windowsFullEnd, false, false, execaSync);165+test('Split stdout - chunk ends with newline, preserveNewlines, sync', testLines, 1, simpleFullEndChunks, noNewlinesChunks, simpleFullEnd, false, false, execaSync);166+test('Split stdout - single newline, preserveNewlines, sync', testLines, 1, newlineChunks, emptyChunks, newlineFull, false, false, execaSync);167+test('Split stdout - only newlines, preserveNewlines, sync', testLines, 1, newlinesChunks, manyEmptyChunks, newlinesFull, false, false, execaSync);168+test('Split stdout - only Windows newlines, preserveNewlines, sync', testLines, 1, windowsNewlinesChunks, manyEmptyChunks, windowsNewlinesFull, false, false, execaSync);169+test('Split stdout - line split over multiple chunks, preserveNewlines, sync', testLines, 1, runOverChunks, noNewlinesChunks, simpleFullEnd, false, false, execaSync);170+test('Split stdout - 0 newlines, big line, preserveNewlines, sync', testLines, 1, bigChunks, bigChunks, bigFullEnd, false, false, execaSync);171+test('Split stdout - 0 newlines, many chunks, preserveNewlines, sync', testLines, 1, manyChunks, manyLines, manyFullEnd, false, false, execaSync);172+test('Split stdout - n newlines, 1 chunk, objectMode, preserveNewlines, sync', testLines, 1, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);173+test('Split stderr - n newlines, 1 chunk, objectMode, preserveNewlines, sync', testLines, 2, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);174+test('Split stdio[*] - n newlines, 1 chunk, objectMode, preserveNewlines, sync', testLines, 3, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);175+test('Split stdout - preserveNewlines, n chunks, objectMode, preserveNewlines, sync', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesLines, true, false, execaSync);176+test('Split stdout - empty, 1 chunk, objectMode, preserveNewlines, sync', testLines, 1, emptyChunks, noLines, noLines, true, false, execaSync);177+test('Split stdout - 0 newlines, 1 chunk, objectMode, preserveNewlines, sync', testLines, 1, singleChunks, singleChunks, singleChunks, true, false, execaSync);178+test('Split stdout - Windows newlines, objectMode, preserveNewlines, sync', testLines, 1, windowsChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);179+test('Split stdout - chunk ends with newline, objectMode, preserveNewlines, sync', testLines, 1, simpleFullEndChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);180+test('Split stdout - single newline, objectMode, preserveNewlines, sync', testLines, 1, newlineChunks, emptyChunks, emptyChunks, true, false, execaSync);181+test('Split stdout - only newlines, objectMode, preserveNewlines, sync', testLines, 1, newlinesChunks, manyEmptyChunks, manyEmptyChunks, true, false, execaSync);182+test('Split stdout - only Windows newlines, objectMode, preserveNewlines, sync', testLines, 1, windowsNewlinesChunks, manyEmptyChunks, manyEmptyChunks, true, false, execaSync);183+test('Split stdout - line split over multiple chunks, objectMode, preserveNewlines, sync', testLines, 1, runOverChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);184+test('Split stdout - 0 newlines, big line, objectMode, preserveNewlines, sync', testLines, 1, bigChunks, bigChunks, bigChunks, true, false, execaSync);185+test('Split stdout - 0 newlines, many chunks, objectMode, preserveNewlines, sync', testLines, 1, manyChunks, manyLines, manyLines, true, false, execaSync);186 187 // eslint-disable-next-line max-params132-const testBinaryOption = async (t, binary, input, expectedLines, expectedOutput, objectMode, preserveNewlines, encoding) => {188+const testBinaryOption = async (t, binary, input, expectedLines, expectedOutput, objectMode, preserveNewlines, encoding, execaMethod) => {189 const lines = [];134- const {stdout} = await execa('noop.js', {190+ const {stdout} = await execaMethod('noop.js', {191 stdout: [192 getOutputsGenerator(input)(false, true),193 resultGenerator(lines)(objectMode, binary, preserveNewlines),194 ],3 unmodified lines198 t.deepEqual(lines, expectedLines);199 t.deepEqual(stdout, expectedOutput);200 };201 146-test('Does not split lines when "binary" is true', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFull, false, true);147-test('Splits lines when "binary" is false', testBinaryOption, false, simpleChunks, simpleLines, simpleFull, false, true);148-test('Splits lines when "binary" is undefined', testBinaryOption, undefined, simpleChunks, simpleLines, simpleFull, false, true);149-test('Does not split lines when "binary" is undefined, encoding "buffer"', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, true, 'buffer');150-test('Does not split lines when "binary" is false, encoding "buffer"', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, true, 'buffer');151-test('Does not split lines when "binary" is undefined, encoding "hex"', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, true, 'hex');152-test('Does not split lines when "binary" is false, encoding "hex"', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, true, 'hex');153-test('Does not split lines when "binary" is true, objectMode', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleChunksUint8Array, true, true);154-test('Splits lines when "binary" is false, objectMode', testBinaryOption, false, simpleChunks, simpleLines, simpleLines, true, true);155-test('Splits lines when "binary" is undefined, objectMode', testBinaryOption, undefined, simpleChunks, simpleLines, simpleLines, true, true);156-test('Does not split lines when "binary" is true, preserveNewlines', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFull, false, false);157-test('Splits lines when "binary" is false, preserveNewlines', testBinaryOption, false, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false);158-test('Splits lines when "binary" is undefined, preserveNewlines', testBinaryOption, undefined, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false);159-test('Does not split lines when "binary" is undefined, encoding "buffer", preserveNewlines', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, false, 'buffer');160-test('Does not split lines when "binary" is false, encoding "buffer", preserveNewlines', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, false, 'buffer');161-test('Does not split lines when "binary" is true, objectMode, preserveNewlines', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleChunksUint8Array, true, false);162-test('Does not split lines when "binary" is undefined, encoding "hex", preserveNewlines', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, false, 'hex');163-test('Does not split lines when "binary" is false, encoding "hex", preserveNewlines', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, false, 'hex');164-test('Splits lines when "binary" is false, objectMode, preserveNewlines', testBinaryOption, false, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false);165-test('Splits lines when "binary" is undefined, objectMode, preserveNewlines', testBinaryOption, undefined, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false);202+test('Does not split lines when "binary" is true', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFull, false, true, 'utf8', execa);203+test('Splits lines when "binary" is false', testBinaryOption, false, simpleChunks, simpleLines, simpleFull, false, true, 'utf8', execa);204+test('Splits lines when "binary" is undefined', testBinaryOption, undefined, simpleChunks, simpleLines, simpleFull, false, true, 'utf8', execa);205+test('Does not split lines when "binary" is undefined, encoding "buffer"', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, true, 'buffer', execa);206+test('Does not split lines when "binary" is false, encoding "buffer"', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, true, 'buffer', execa);207+test('Does not split lines when "binary" is undefined, encoding "hex"', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, true, 'hex', execa);208+test('Does not split lines when "binary" is false, encoding "hex"', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, true, 'hex', execa);209+test('Does not split lines when "binary" is true, objectMode', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleChunksUint8Array, true, true, 'utf8', execa);210+test('Splits lines when "binary" is false, objectMode', testBinaryOption, false, simpleChunks, simpleLines, simpleLines, true, true, 'utf8', execa);211+test('Splits lines when "binary" is undefined, objectMode', testBinaryOption, undefined, simpleChunks, simpleLines, simpleLines, true, true, 'utf8', execa);212+test('Does not split lines when "binary" is true, preserveNewlines', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFull, false, false, 'utf8', execa);213+test('Splits lines when "binary" is false, preserveNewlines', testBinaryOption, false, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, 'utf8', execa);214+test('Splits lines when "binary" is undefined, preserveNewlines', testBinaryOption, undefined, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, 'utf8', execa);215+test('Does not split lines when "binary" is undefined, encoding "buffer", preserveNewlines', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, false, 'buffer', execa);216+test('Does not split lines when "binary" is false, encoding "buffer", preserveNewlines', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, false, 'buffer', execa);217+test('Does not split lines when "binary" is true, objectMode, preserveNewlines', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleChunksUint8Array, true, false, 'utf8', execa);218+test('Does not split lines when "binary" is undefined, encoding "hex", preserveNewlines', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, false, 'hex', execa);219+test('Does not split lines when "binary" is false, encoding "hex", preserveNewlines', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, false, 'hex', execa);220+test('Splits lines when "binary" is false, objectMode, preserveNewlines', testBinaryOption, false, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, 'utf8', execa);221+test('Splits lines when "binary" is undefined, objectMode, preserveNewlines', testBinaryOption, undefined, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, 'utf8', execa);222+test('Does not split lines when "binary" is true, sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFull, false, true, 'utf8', execaSync);223+test('Splits lines when "binary" is false, sync', testBinaryOption, false, simpleChunks, simpleLines, simpleFull, false, true, 'utf8', execaSync);224+test('Splits lines when "binary" is undefined, sync', testBinaryOption, undefined, simpleChunks, simpleLines, simpleFull, false, true, 'utf8', execaSync);225+test('Does not split lines when "binary" is undefined, encoding "buffer", sync', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, true, 'buffer', execaSync);226+test('Does not split lines when "binary" is false, encoding "buffer", sync', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, true, 'buffer', execaSync);227+test('Does not split lines when "binary" is undefined, encoding "hex", sync', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, true, 'hex', execaSync);228+test('Does not split lines when "binary" is false, encoding "hex", sync', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, true, 'hex', execaSync);229+test('Does not split lines when "binary" is true, objectMode, sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleChunksUint8Array, true, true, 'utf8', execaSync);230+test('Splits lines when "binary" is false, objectMode, sync', testBinaryOption, false, simpleChunks, simpleLines, simpleLines, true, true, 'utf8', execaSync);231+test('Splits lines when "binary" is undefined, objectMode, sync', testBinaryOption, undefined, simpleChunks, simpleLines, simpleLines, true, true, 'utf8', execaSync);232+test('Does not split lines when "binary" is true, preserveNewlines, sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFull, false, false, 'utf8', execaSync);233+test('Splits lines when "binary" is false, preserveNewlines, sync', testBinaryOption, false, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, 'utf8', execaSync);234+test('Splits lines when "binary" is undefined, preserveNewlines, sync', testBinaryOption, undefined, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, 'utf8', execaSync);235+test('Does not split lines when "binary" is undefined, encoding "buffer", preserveNewlines, sync', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, false, 'buffer', execaSync);236+test('Does not split lines when "binary" is false, encoding "buffer", preserveNewlines, sync', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, false, 'buffer', execaSync);237+test('Does not split lines when "binary" is true, objectMode, preserveNewlines, sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleChunksUint8Array, true, false, 'utf8', execaSync);238+test('Does not split lines when "binary" is undefined, encoding "hex", preserveNewlines, sync', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, false, 'hex', execaSync);239+test('Does not split lines when "binary" is false, encoding "hex", preserveNewlines, sync', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, false, 'hex', execaSync);240+test('Splits lines when "binary" is false, objectMode, preserveNewlines, sync', testBinaryOption, false, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, 'utf8', execaSync);241+test('Splits lines when "binary" is undefined, objectMode, preserveNewlines, sync', testBinaryOption, undefined, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, 'utf8', execaSync);242 243 const resultUint8ArrayGenerator = function * (lines, chunk) {244 lines.push(chunk);245 yield new TextEncoder().encode(chunk);17 unmodified lines263 test('Line splitting when converting from string to Uint8Array, objectMode', testStringToUint8Array, [foobarUint8Array], true, true);264 test('Line splitting when converting from string to Uint8Array, preserveNewlines', testStringToUint8Array, [foobarString], false, false);265 test('Line splitting when converting from string to Uint8Array, objectMode, preserveNewlines', testStringToUint8Array, [foobarUint8Array], true, false);266 191-const testStripNewline = async (t, input, expectedOutput) => {192- const {stdout} = await execa('noop.js', {267+const testStripNewline = async (t, input, expectedOutput, execaMethod) => {268+ const {stdout} = await execaMethod('noop.js', {269 stdout: getOutputsGenerator([input])(),270 stripFinalNewline: false,271 });272 t.is(stdout, expectedOutput);273 };274 199-test('Strips newline when user do not mistakenly yield one at the end', testStripNewline, singleFull, singleFullEnd);200-test('Strips newline when user mistakenly yielded one at the end', testStripNewline, singleFullEnd, singleFullEnd);201-test('Strips newline when user mistakenly yielded one at the end, Windows newline', testStripNewline, singleFullEndWindows, singleFullEndWindows);275+test('Strips newline when user do not mistakenly yield one at the end', testStripNewline, singleFull, singleFullEnd, execa);276+test('Strips newline when user mistakenly yielded one at the end', testStripNewline, singleFullEnd, singleFullEnd, execa);277+test('Strips newline when user mistakenly yielded one at the end, Windows newline', testStripNewline, singleFullEndWindows, singleFullEndWindows, execa);278+test('Strips newline when user do not mistakenly yield one at the end, sync', testStripNewline, singleFull, singleFullEnd, execaSync);279+test('Strips newline when user mistakenly yielded one at the end, sync', testStripNewline, singleFullEnd, singleFullEnd, execaSync);280+test('Strips newline when user mistakenly yielded one at the end, Windows newline, sync', testStripNewline, singleFullEndWindows, singleFullEndWindows, execaSync);281 203-const testMixNewlines = async (t, generator) => {204- const {stdout} = await execa('noop-fd.js', ['1', mixedNewlines], {282+const testMixNewlines = async (t, generator, execaMethod) => {283+ const {stdout} = await execaMethod('noop-fd.js', ['1', mixedNewlines], {284 stdout: generator(),285 stripFinalNewline: false,286 });287 t.is(stdout, mixedNewlines);288 };289 211-test('Can mix Unix and Windows newlines', testMixNewlines, noopGenerator);212-test('Can mix Unix and Windows newlines, async', testMixNewlines, noopAsyncGenerator);290+test('Can mix Unix and Windows newlines', testMixNewlines, noopGenerator, execa);291+test('Can mix Unix and Windows newlines, sync', testMixNewlines, noopGenerator, execaSync);292+test('Can mix Unix and Windows newlines, async', testMixNewlines, noopAsyncGenerator, execa);293 294 const serializeResultGenerator = function * (lines, chunk) {295 lines.push(chunk);296 yield JSON.stringify(chunk);297 };298 219-const testUnsetObjectMode = async (t, expectedOutput, preserveNewlines) => {299+const testUnsetObjectMode = async (t, expectedOutput, preserveNewlines, execaMethod) => {300 const lines = [];221- const {stdout} = await execa('noop.js', {301+ const {stdout} = await execaMethod('noop.js', {302 stdout: [303 getOutputsGenerator([foobarObject])(true),304 {transform: serializeResultGenerator.bind(undefined, lines), preserveNewlines, objectMode: false},305 ],2 unmodified lines308 t.deepEqual(lines, [foobarObject]);309 t.is(stdout, expectedOutput);310 };311 232-test('Can switch from objectMode to non-objectMode', testUnsetObjectMode, `${foobarObjectString}\n`, false);233-test('Can switch from objectMode to non-objectMode, preserveNewlines', testUnsetObjectMode, foobarObjectString, true);312+test('Can switch from objectMode to non-objectMode', testUnsetObjectMode, `${foobarObjectString}\n`, false, execa);313+test('Can switch from objectMode to non-objectMode, preserveNewlines', testUnsetObjectMode, foobarObjectString, true, execa);314+test('Can switch from objectMode to non-objectMode, sync', testUnsetObjectMode, `${foobarObjectString}\n`, false, execaSync);315+test('Can switch from objectMode to non-objectMode, preserveNewlines, sync', testUnsetObjectMode, foobarObjectString, true, execaSync);316 317+// eslint-disable-next-line max-params235-const testYieldArray = async (t, input, expectedLines, expectedOutput) => {318+const testYieldArray = async (t, input, expectedLines, expectedOutput, execaMethod) => {319 const lines = [];237- const {stdout} = await execa('noop.js', {320+ const {stdout} = await execaMethod('noop.js', {321 stdout: [322 getOutputsGenerator(input)(),323 resultGenerator(lines)(),324 ],2 unmodified lines327 t.deepEqual(lines, expectedLines);328 t.deepEqual(stdout, expectedOutput);329 };330 248-test('Can use "yield* array" to produce multiple lines', testYieldArray, [foobarString, foobarString], [foobarString, foobarString], `${foobarString}\n${foobarString}\n`);249-test('Can use "yield* array" to produce empty lines', testYieldArray, [foobarString, ''], [foobarString, ''], `${foobarString}\n\n`);331+test('Can use "yield* array" to produce multiple lines', testYieldArray, [foobarString, foobarString], [foobarString, foobarString], `${foobarString}\n${foobarString}\n`, execa);332+test('Can use "yield* array" to produce empty lines', testYieldArray, [foobarString, ''], [foobarString, ''], `${foobarString}\n\n`, execa);333+test('Can use "yield* array" to produce multiple lines, sync', testYieldArray, [foobarString, foobarString], [foobarString, foobarString], `${foobarString}\n${foobarString}\n`, execaSync);334+test('Can use "yield* array" to produce empty lines, sync', testYieldArray, [foobarString, ''], [foobarString, ''], `${foobarString}\n\n`, execaSync);modified:test/stdio/sync.js-11 removed
8 unmodified lines9 setFixtureDir();10 11 const getArrayMessage = singleValueName => `The \`${singleValueName}\` option cannot be set as an array`;12 const getInputMessage = (singleValueName, inputName) => `The \`${singleValueName}\` and the \`${inputName}\` options cannot be both set`;13-const getFd3InputMessage = type => `not \`stdio[3]\`, can be ${type}`;13 14 const inputOptions = {input: ''};15 const inputFileOptions = {inputFile: fileURLToPath(import.meta.url)};16 27 unmodified lines44 test('Cannot use [Writable, "pipe"] with stderr, sync', testInvalidStdioArraySync, 2, [noopWritable(), 'pipe'], {}, getArrayMessage('stderr: Stream'));45 test('Cannot use ["inherit", "pipe"] with stdio[*], sync', testInvalidStdioArraySync, 3, ['inherit', 'pipe'], {}, getArrayMessage('stdio[3]: "inherit"'));46 test('Cannot use [3, "pipe"] with stdio[*], sync', testInvalidStdioArraySync, 3, [3, 'pipe'], {}, getArrayMessage('stdio[3]: 3'));47 test('Cannot use [Writable, "pipe"] with stdio[*], sync', testInvalidStdioArraySync, 3, [noopWritable(), 'pipe'], {}, getArrayMessage('stdio[3]: Stream'));49-50-const testFd3InputSync = (t, stdioOption, expectedMessage) => {51- const {message} = t.throws(() => {52- execaSync('empty.js', getStdio(3, stdioOption));53- });54- t.true(message.includes(expectedMessage));55-};56-57-test('Cannot use Uint8Array with stdio[*], sync', testFd3InputSync, new Uint8Array(), getFd3InputMessage('a Uint8Array'));58-test('Cannot use iterable with stdio[*], sync', testFd3InputSync, [[]], getFd3InputMessage('an iterable'));modified:test/stdio/transform.js+88 added-54 removed
1 unmodified line2 import {once} from 'node:events';3 import {scheduler} from 'node:timers/promises';4 import test from 'ava';5 import {getStreamAsArray} from 'get-stream';6-import {execa} from '../../index.js';6+import {execa, execaSync} from '../../index.js';7 import {foobarString} from '../helpers/input.js';8 import {9 noopGenerator,10 getOutputAsyncGenerator,2 unmodified lines13 outputObjectGenerator,14 convertTransformToFinal,15 prefix,16 suffix,17- GENERATOR_ERROR_REGEXP,17 } from '../helpers/generator.js';18 import {generatorsMap} from '../helpers/map.js';19 import {defaultHighWaterMark} from '../helpers/stream.js';20 import {setFixtureDir} from '../helpers/fixtures-dir.js';21 22 setFixtureDir();23 25-const testGeneratorFinal = async (t, fixtureName) => {26- const {stdout} = await execa(fixtureName, {stdout: convertTransformToFinal(getOutputGenerator(foobarString)(), true)});24+const testGeneratorFinal = async (t, fixtureName, execaMethod) => {25+ const {stdout} = await execaMethod(fixtureName, {stdout: convertTransformToFinal(getOutputGenerator(foobarString)(), true)});26 t.is(stdout, foobarString);27 };28 30-test('Generators "final" can be used', testGeneratorFinal, 'noop.js');31-test('Generators "final" is used even on empty streams', testGeneratorFinal, 'empty.js');29+test('Generators "final" can be used', testGeneratorFinal, 'noop.js', execa);30+test('Generators "final" is used even on empty streams', testGeneratorFinal, 'empty.js', execa);31+test('Generators "final" can be used, sync', testGeneratorFinal, 'noop.js', execaSync);32+test('Generators "final" is used even on empty streams, sync', testGeneratorFinal, 'empty.js', execaSync);33 33-const testFinalAlone = async (t, final) => {34- const {stdout} = await execa('noop-fd.js', ['1', '.'], {stdout: {final: final(foobarString)().transform, binary: true}});34+const testFinalAlone = async (t, final, execaMethod) => {35+ const {stdout} = await execaMethod('noop-fd.js', ['1', '.'], {stdout: {final: final(foobarString)().transform, binary: true}});36 t.is(stdout, `.${foobarString}`);37 };38 38-test('Generators "final" can be used without "transform"', testFinalAlone, getOutputGenerator);39-test('Generators "final" can be used without "transform", async', testFinalAlone, getOutputAsyncGenerator);39+test('Generators "final" can be used without "transform"', testFinalAlone, getOutputGenerator, execa);40+test('Generators "final" can be used without "transform", sync', testFinalAlone, getOutputGenerator, execaSync);41+test('Generators "final" can be used without "transform", async', testFinalAlone, getOutputAsyncGenerator, execa);42 41-const testFinalNoOutput = async (t, final) => {42- const {stdout} = await execa('empty.js', {stdout: {final: final(foobarString)().transform}});43+const testFinalNoOutput = async (t, final, execaMethod) => {44+ const {stdout} = await execaMethod('empty.js', {stdout: {final: final(foobarString)().transform}});45 t.is(stdout, foobarString);46 };47 46-test('Generators "final" can be used without "transform" nor output', testFinalNoOutput, getOutputGenerator);47-test('Generators "final" can be used without "transform" nor output, async', testFinalNoOutput, getOutputAsyncGenerator);48+test('Generators "final" can be used without "transform" nor output', testFinalNoOutput, getOutputGenerator, execa);49+test('Generators "final" can be used without "transform" nor output, sync', testFinalNoOutput, getOutputGenerator, execaSync);50+test('Generators "final" can be used without "transform" nor output, async', testFinalNoOutput, getOutputAsyncGenerator, execa);51 52 const repeatCount = defaultHighWaterMark * 3;53 54 const writerGenerator = function * () {6 unmodified lines61 t.is(chunk.length, 1);62 yield chunk;63 };64 65+// eslint-disable-next-line max-params62-const testHighWaterMark = async (t, passThrough, binary, objectMode) => {63- const {stdout} = await execa('noop.js', {66+const testHighWaterMark = async (t, passThrough, binary, objectMode, execaMethod) => {67+ const {stdout} = await execaMethod('noop.js', {68 stdout: [69 ...(objectMode ? [outputObjectGenerator()] : []),70 writerGenerator,71 ...(passThrough ? [noopGenerator(false, binary)] : []),3 unmodified lines75 t.is(stdout.length, repeatCount);76 t.true(stdout.every(chunk => chunk === '\n'));77 };78 75-test('Synchronous yields are not buffered, no passThrough', testHighWaterMark, false, false, false);76-test('Synchronous yields are not buffered, line-wise passThrough', testHighWaterMark, true, false, false);77-test('Synchronous yields are not buffered, binary passThrough', testHighWaterMark, true, true, false);78-test('Synchronous yields are not buffered, objectMode as input but not output', testHighWaterMark, false, false, true);79+test('Synchronous yields are not buffered, no passThrough', testHighWaterMark, false, false, false, execa);80+test('Synchronous yields are not buffered, line-wise passThrough', testHighWaterMark, true, false, false, execa);81+test('Synchronous yields are not buffered, binary passThrough', testHighWaterMark, true, true, false, execa);82+test('Synchronous yields are not buffered, objectMode as input but not output', testHighWaterMark, false, false, true, execa);83+test('Synchronous yields are not buffered, no passThrough, sync', testHighWaterMark, false, false, false, execaSync);84+test('Synchronous yields are not buffered, line-wise passThrough, sync', testHighWaterMark, true, false, false, execaSync);85+test('Synchronous yields are not buffered, binary passThrough, sync', testHighWaterMark, true, true, false, execaSync);86+test('Synchronous yields are not buffered, objectMode as input but not output, sync', testHighWaterMark, false, false, true, execaSync);87 88 // eslint-disable-next-line max-params81-const testNoYield = async (t, type, objectMode, final, output) => {82- const {stdout} = await execa('noop.js', {stdout: convertTransformToFinal(generatorsMap[type].noYield(objectMode), final)});89+const testNoYield = async (t, type, objectMode, final, output, execaMethod) => {90+ const {stdout} = await execaMethod('noop.js', {stdout: convertTransformToFinal(generatorsMap[type].noYield(objectMode), final)});91 t.deepEqual(stdout, output);92 };93 86-test('Generator can filter "transform" by not calling yield', testNoYield, 'generator', false, false, '');87-test('Generator can filter "transform" by not calling yield, objectMode', testNoYield, 'generator', true, false, []);88-test('Generator can filter "final" by not calling yield', testNoYield, 'generator', false, true, '');89-test('Generator can filter "final" by not calling yield, objectMode', testNoYield, 'generator', true, true, []);90-test('Duplex can filter by not calling push', testNoYield, 'duplex', false, false, '');91-test('Duplex can filter by not calling push, objectMode', testNoYield, 'duplex', true, false, []);92-test('WebTransform can filter by not calling push', testNoYield, 'webTransform', false, false, '');93-test('WebTransform can filter by not calling push, objectMode', testNoYield, 'webTransform', true, false, []);94+test('Generator can filter "transform" by not calling yield', testNoYield, 'generator', false, false, '', execa);95+test('Generator can filter "transform" by not calling yield, objectMode', testNoYield, 'generator', true, false, [], execa);96+test('Generator can filter "final" by not calling yield', testNoYield, 'generator', false, true, '', execa);97+test('Generator can filter "final" by not calling yield, objectMode', testNoYield, 'generator', true, true, [], execa);98+test('Generator can filter "transform" by not calling yield, sync', testNoYield, 'generator', false, false, '', execaSync);99+test('Generator can filter "transform" by not calling yield, objectMode, sync', testNoYield, 'generator', true, false, [], execaSync);100+test('Generator can filter "final" by not calling yield, sync', testNoYield, 'generator', false, true, '', execaSync);101+test('Generator can filter "final" by not calling yield, objectMode, sync', testNoYield, 'generator', true, true, [], execaSync);102+test('Duplex can filter by not calling push', testNoYield, 'duplex', false, false, '', execa);103+test('Duplex can filter by not calling push, objectMode', testNoYield, 'duplex', true, false, [], execa);104+test('WebTransform can filter by not calling push', testNoYield, 'webTransform', false, false, '', execa);105+test('WebTransform can filter by not calling push, objectMode', testNoYield, 'webTransform', true, false, [], execa);106 107 const testMultipleYields = async (t, type, final, binary) => {108 const {stdout} = await execa('noop-fd.js', ['1', foobarString], {stdout: convertTransformToFinal(generatorsMap[type].multipleYield(), final)});109 const newline = binary ? '' : '\n';76 unmodified lines186 test('Generators "final" is awaited on success', testAsyncGenerators, 'generator', true);187 test('Duplex is awaited on success', testAsyncGenerators, 'duplex', false);188 test('WebTransform is awaited on success', testAsyncGenerators, 'webTransform', false);189 178-const testThrowingGenerator = async (t, type, final) => {179- await t.throwsAsync(180- execa('noop-fd.js', ['1', foobarString], {stdout: convertTransformToFinal(generatorsMap[type].throwing(), final)}),181- {message: GENERATOR_ERROR_REGEXP},182- );190+const assertProcessError = async (t, type, execaMethod, getSubprocess) => {191+ const cause = new Error(foobarString);192+ const transform = generatorsMap[type].throwing(cause)();193+ const error = execaMethod === execa194+ ? await t.throwsAsync(getSubprocess(transform))195+ : t.throws(() => {196+ getSubprocess(transform);197+ });198+ t.is(error.cause, cause);199 };200 185-test('Generators "transform" errors make subprocess fail', testThrowingGenerator, 'generator', false);186-test('Generators "final" errors make subprocess fail', testThrowingGenerator, 'generator', true);187-test('Duplexes "transform" errors make subprocess fail', testThrowingGenerator, 'duplex', false);188-test('WebTransform "transform" errors make subprocess fail', testThrowingGenerator, 'webTransform', false);201+const testThrowingGenerator = async (t, type, final, execaMethod) => {202+ await assertProcessError(t, type, execaMethod, transform => execaMethod('noop.js', {203+ stdout: convertTransformToFinal(transform, final),204+ }));205+};206 190-const testSingleErrorOutput = async (t, type) => {191- await t.throwsAsync(192- execa('noop-fd.js', ['1', foobarString], {stdout: [generatorsMap[type].noop(false), generatorsMap[type].throwing(), generatorsMap[type].noop(false)]}),193- {message: GENERATOR_ERROR_REGEXP},194- );207+test('Generators "transform" errors make subprocess fail', testThrowingGenerator, 'generator', false, execa);208+test('Generators "final" errors make subprocess fail', testThrowingGenerator, 'generator', true, execa);209+test('Generators "transform" errors make subprocess fail, sync', testThrowingGenerator, 'generator', false, execaSync);210+test('Generators "final" errors make subprocess fail, sync', testThrowingGenerator, 'generator', true, execaSync);211+test('Duplexes "transform" errors make subprocess fail', testThrowingGenerator, 'duplex', false, execa);212+test('WebTransform "transform" errors make subprocess fail', testThrowingGenerator, 'webTransform', false, execa);213+214+const testSingleErrorOutput = async (t, type, execaMethod) => {215+ await assertProcessError(t, type, execaMethod, transform => execaMethod('noop.js', {216+ stdout: [217+ generatorsMap[type].noop(false),218+ transform,219+ generatorsMap[type].noop(false),220+ ],221+ }));222 };223 197-test('Generators errors make subprocess fail even when other output generators do not throw', testSingleErrorOutput, 'generator');198-test('Duplexes errors make subprocess fail even when other output generators do not throw', testSingleErrorOutput, 'duplex');199-test('WebTransform errors make subprocess fail even when other output generators do not throw', testSingleErrorOutput, 'webTransform');224+test('Generators errors make subprocess fail even when other output generators do not throw', testSingleErrorOutput, 'generator', execa);225+test('Generators errors make subprocess fail even when other output generators do not throw, sync', testSingleErrorOutput, 'generator', execaSync);226+test('Duplexes errors make subprocess fail even when other output generators do not throw', testSingleErrorOutput, 'duplex', execa);227+test('WebTransform errors make subprocess fail even when other output generators do not throw', testSingleErrorOutput, 'webTransform', execa);228 201-const testSingleErrorInput = async (t, type) => {202- const subprocess = execa('stdin-fd.js', ['0'], {stdin: [generatorsMap[type].noop(false), generatorsMap[type].throwing(), generatorsMap[type].noop(false)]});203- subprocess.stdin.write('foobar\n');204- await t.throwsAsync(subprocess, {message: GENERATOR_ERROR_REGEXP});229+const testSingleErrorInput = async (t, type, execaMethod) => {230+ await assertProcessError(t, type, execaMethod, transform => execaMethod('stdin.js', {231+ stdin: [232+ ['foobar\n'],233+ generatorsMap[type].noop(false),234+ transform,235+ generatorsMap[type].noop(false),236+ ],237+ }));238 };239 207-test('Generators errors make subprocess fail even when other input generators do not throw', testSingleErrorInput, 'generator');208-test('Duplexes errors make subprocess fail even when other input generators do not throw', testSingleErrorInput, 'duplex');209-test('WebTransform errors make subprocess fail even when other input generators do not throw', testSingleErrorInput, 'webTransform');240+test('Generators errors make subprocess fail even when other input generators do not throw', testSingleErrorInput, 'generator', execa);241+test('Generators errors make subprocess fail even when other input generators do not throw, sync', testSingleErrorInput, 'generator', execaSync);242+test('Duplexes errors make subprocess fail even when other input generators do not throw', testSingleErrorInput, 'duplex', execa);243+test('WebTransform errors make subprocess fail even when other input generators do not throw', testSingleErrorInput, 'webTransform', execa);244 245 const testGeneratorCancel = async (t, error) => {246 const subprocess = execa('noop.js', {stdout: infiniteGenerator()});247 await once(subprocess.stdout, 'data');21 unmodified linesmodified:test/stdio/type.js+45 added-39 removed
7 unmodified lines8 import {setFixtureDir} from '../helpers/fixtures-dir.js';9 10 setFixtureDir();11 12-const testInvalidGenerator = (t, fdNumber, stdioOption) => {12+const testInvalidGenerator = (t, fdNumber, stdioOption, execaMethod) => {13 t.throws(() => {14- execa('empty.js', getStdio(fdNumber, {...noopGenerator(), ...stdioOption}));14+ execaMethod('empty.js', getStdio(fdNumber, {...noopGenerator(), ...stdioOption}));15 }, {message: 'final' in stdioOption ? /must be a generator/ : /must be a generator, a Duplex stream or a web TransformStream/});16 };17 18-test('Cannot use invalid "transform" with stdin', testInvalidGenerator, 0, {transform: true});19-test('Cannot use invalid "transform" with stdout', testInvalidGenerator, 1, {transform: true});20-test('Cannot use invalid "transform" with stderr', testInvalidGenerator, 2, {transform: true});21-test('Cannot use invalid "transform" with stdio[*]', testInvalidGenerator, 3, {transform: true});22-test('Cannot use invalid "final" with stdin', testInvalidGenerator, 0, {final: true});23-test('Cannot use invalid "final" with stdout', testInvalidGenerator, 1, {final: true});24-test('Cannot use invalid "final" with stderr', testInvalidGenerator, 2, {final: true});25-test('Cannot use invalid "final" with stdio[*]', testInvalidGenerator, 3, {final: true});18+test('Cannot use invalid "transform" with stdin', testInvalidGenerator, 0, {transform: true}, execa);19+test('Cannot use invalid "transform" with stdout', testInvalidGenerator, 1, {transform: true}, execa);20+test('Cannot use invalid "transform" with stderr', testInvalidGenerator, 2, {transform: true}, execa);21+test('Cannot use invalid "transform" with stdio[*]', testInvalidGenerator, 3, {transform: true}, execa);22+test('Cannot use invalid "final" with stdin', testInvalidGenerator, 0, {final: true}, execa);23+test('Cannot use invalid "final" with stdout', testInvalidGenerator, 1, {final: true}, execa);24+test('Cannot use invalid "final" with stderr', testInvalidGenerator, 2, {final: true}, execa);25+test('Cannot use invalid "final" with stdio[*]', testInvalidGenerator, 3, {final: true}, execa);26+test('Cannot use invalid "transform" with stdin, sync', testInvalidGenerator, 0, {transform: true}, execaSync);27+test('Cannot use invalid "transform" with stdout, sync', testInvalidGenerator, 1, {transform: true}, execaSync);28+test('Cannot use invalid "transform" with stderr, sync', testInvalidGenerator, 2, {transform: true}, execaSync);29+test('Cannot use invalid "transform" with stdio[*], sync', testInvalidGenerator, 3, {transform: true}, execaSync);30+test('Cannot use invalid "final" with stdin, sync', testInvalidGenerator, 0, {final: true}, execaSync);31+test('Cannot use invalid "final" with stdout, sync', testInvalidGenerator, 1, {final: true}, execaSync);32+test('Cannot use invalid "final" with stderr, sync', testInvalidGenerator, 2, {final: true}, execaSync);33+test('Cannot use invalid "final" with stdio[*], sync', testInvalidGenerator, 3, {final: true}, execaSync);34 35+// eslint-disable-next-line max-params27-const testInvalidBinary = (t, fdNumber, optionName, type) => {36+const testInvalidBinary = (t, fdNumber, optionName, type, execaMethod) => {37 t.throws(() => {29- execa('empty.js', getStdio(fdNumber, {...generatorsMap[type].uppercase(), [optionName]: 'true'}));38+ execaMethod('empty.js', getStdio(fdNumber, {...generatorsMap[type].uppercase(), [optionName]: 'true'}));39 }, {message: /a boolean/});40 };41 33-test('Cannot use invalid "binary" with stdin', testInvalidBinary, 0, 'binary', 'generator');34-test('Cannot use invalid "binary" with stdout', testInvalidBinary, 1, 'binary', 'generator');35-test('Cannot use invalid "binary" with stderr', testInvalidBinary, 2, 'binary', 'generator');36-test('Cannot use invalid "binary" with stdio[*]', testInvalidBinary, 3, 'binary', 'generator');37-test('Cannot use invalid "objectMode" with stdin, generators', testInvalidBinary, 0, 'objectMode', 'generator');38-test('Cannot use invalid "objectMode" with stdout, generators', testInvalidBinary, 1, 'objectMode', 'generator');39-test('Cannot use invalid "objectMode" with stderr, generators', testInvalidBinary, 2, 'objectMode', 'generator');40-test('Cannot use invalid "objectMode" with stdio[*], generators', testInvalidBinary, 3, 'objectMode', 'generator');41-test('Cannot use invalid "objectMode" with stdin, duplexes', testInvalidBinary, 0, 'objectMode', 'duplex');42-test('Cannot use invalid "objectMode" with stdout, duplexes', testInvalidBinary, 1, 'objectMode', 'duplex');43-test('Cannot use invalid "objectMode" with stderr, duplexes', testInvalidBinary, 2, 'objectMode', 'duplex');44-test('Cannot use invalid "objectMode" with stdio[*], duplexes', testInvalidBinary, 3, 'objectMode', 'duplex');45-test('Cannot use invalid "objectMode" with stdin, webTransforms', testInvalidBinary, 0, 'objectMode', 'webTransform');46-test('Cannot use invalid "objectMode" with stdout, webTransforms', testInvalidBinary, 1, 'objectMode', 'webTransform');47-test('Cannot use invalid "objectMode" with stderr, webTransforms', testInvalidBinary, 2, 'objectMode', 'webTransform');48-test('Cannot use invalid "objectMode" with stdio[*], webTransforms', testInvalidBinary, 3, 'objectMode', 'webTransform');42+test('Cannot use invalid "binary" with stdin', testInvalidBinary, 0, 'binary', 'generator', execa);43+test('Cannot use invalid "binary" with stdout', testInvalidBinary, 1, 'binary', 'generator', execa);44+test('Cannot use invalid "binary" with stderr', testInvalidBinary, 2, 'binary', 'generator', execa);45+test('Cannot use invalid "binary" with stdio[*]', testInvalidBinary, 3, 'binary', 'generator', execa);46+test('Cannot use invalid "objectMode" with stdin, generators', testInvalidBinary, 0, 'objectMode', 'generator', execa);47+test('Cannot use invalid "objectMode" with stdout, generators', testInvalidBinary, 1, 'objectMode', 'generator', execa);48+test('Cannot use invalid "objectMode" with stderr, generators', testInvalidBinary, 2, 'objectMode', 'generator', execa);49+test('Cannot use invalid "objectMode" with stdio[*], generators', testInvalidBinary, 3, 'objectMode', 'generator', execa);50+test('Cannot use invalid "binary" with stdin, sync', testInvalidBinary, 0, 'binary', 'generator', execaSync);51+test('Cannot use invalid "binary" with stdout, sync', testInvalidBinary, 1, 'binary', 'generator', execaSync);52+test('Cannot use invalid "binary" with stderr, sync', testInvalidBinary, 2, 'binary', 'generator', execaSync);53+test('Cannot use invalid "binary" with stdio[*], sync', testInvalidBinary, 3, 'binary', 'generator', execaSync);54+test('Cannot use invalid "objectMode" with stdin, generators, sync', testInvalidBinary, 0, 'objectMode', 'generator', execaSync);55+test('Cannot use invalid "objectMode" with stdout, generators, sync', testInvalidBinary, 1, 'objectMode', 'generator', execaSync);56+test('Cannot use invalid "objectMode" with stderr, generators, sync', testInvalidBinary, 2, 'objectMode', 'generator', execaSync);57+test('Cannot use invalid "objectMode" with stdio[*], generators, sync', testInvalidBinary, 3, 'objectMode', 'generator', execaSync);58+test('Cannot use invalid "objectMode" with stdin, duplexes', testInvalidBinary, 0, 'objectMode', 'duplex', execa);59+test('Cannot use invalid "objectMode" with stdout, duplexes', testInvalidBinary, 1, 'objectMode', 'duplex', execa);60+test('Cannot use invalid "objectMode" with stderr, duplexes', testInvalidBinary, 2, 'objectMode', 'duplex', execa);61+test('Cannot use invalid "objectMode" with stdio[*], duplexes', testInvalidBinary, 3, 'objectMode', 'duplex', execa);62+test('Cannot use invalid "objectMode" with stdin, webTransforms', testInvalidBinary, 0, 'objectMode', 'webTransform', execa);63+test('Cannot use invalid "objectMode" with stdout, webTransforms', testInvalidBinary, 1, 'objectMode', 'webTransform', execa);64+test('Cannot use invalid "objectMode" with stderr, webTransforms', testInvalidBinary, 2, 'objectMode', 'webTransform', execa);65+test('Cannot use invalid "objectMode" with stdio[*], webTransforms', testInvalidBinary, 3, 'objectMode', 'webTransform', execa);66 67 // eslint-disable-next-line max-params68 const testUndefinedOption = (t, fdNumber, optionName, type, optionValue) => {69 t.throws(() => {43 unmodified lines113 test('Cannot use "final" with webTransforms and stdout, with transform', testUndefinedFinal, 1, 'webTransform', true);114 test('Cannot use "final" with webTransforms and stderr, with transform', testUndefinedFinal, 2, 'webTransform', true);115 test('Cannot use "final" with webTransforms and stdio[*], with transform', testUndefinedFinal, 3, 'webTransform', true);116 100-const testSyncMethodsGenerator = (t, fdNumber) => {101- t.throws(() => {102- execaSync('empty.js', getStdio(fdNumber, uppercaseGenerator()));103- }, {message: /cannot be a generator/});104-};105-106-test('Cannot use generators with sync methods and stdin', testSyncMethodsGenerator, 0);107-test('Cannot use generators with sync methods and stdout', testSyncMethodsGenerator, 1);108-test('Cannot use generators with sync methods and stderr', testSyncMethodsGenerator, 2);109-test('Cannot use generators with sync methods and stdio[*]', testSyncMethodsGenerator, 3);110-117 const testSyncMethodsDuplex = (t, fdNumber, type) => {118 t.throws(() => {119 execaSync('empty.js', getStdio(fdNumber, generatorsMap[type].uppercase()));120 }, {message: type === 'duplex' ? /cannot be a Duplex stream/ : /cannot be a web TransformStream/});10 unmodified linesmodified:test/stdio/typed-array.js+7 added-8 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3 import {setFixtureDir} from '../helpers/fixtures-dir.js';4 import {getStdio} from '../helpers/stdio.js';5-import {foobarUint8Array} from '../helpers/input.js';5+import {foobarUint8Array, foobarString} from '../helpers/input.js';6 7 setFixtureDir();8 9-const testUint8Array = async (t, fdNumber) => {10- const {stdout} = await execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, foobarUint8Array));11- t.is(stdout, 'foobar');9+const testUint8Array = async (t, fdNumber, execaMethod) => {10+ const {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, foobarUint8Array));11+ t.is(stdout, foobarString);12 };13 14-test('stdin option can be a Uint8Array', testUint8Array, 0);15-test('stdio[*] option can be a Uint8Array', testUint8Array, 3);16-test('stdin option can be a Uint8Array - sync', testUint8Array, 0);17-test('stdio[*] option can be a Uint8Array - sync', testUint8Array, 3);14+test('stdin option can be a Uint8Array', testUint8Array, 0, execa);15+test('stdio[*] option can be a Uint8Array', testUint8Array, 3, execa);16+test('stdin option can be a Uint8Array - sync', testUint8Array, 0, execaSync);17 18 const testNoUint8ArrayOutput = (t, fdNumber, execaMethod) => {19 t.throws(() => {20 execaMethod('empty.js', getStdio(fdNumber, foobarUint8Array));7 unmodified linesmodified:test/stdio/validate.js+46 added-11 removed
1 import {Buffer} from 'node:buffer';2 import test from 'ava';3-import {execa} from '../../index.js';3+import {execa, execaSync} from '../../index.js';4 import {setFixtureDir} from '../helpers/fixtures-dir.js';5 import {getStdio} from '../helpers/stdio.js';6 import {foobarUint8Array, foobarBuffer, foobarObject} from '../helpers/input.js';7 import {serializeGenerator, getOutputGenerator, convertTransformToFinal} from '../helpers/generator.js';8 9 setFixtureDir();10 11-// eslint-disable-next-line max-params12-const testGeneratorReturn = async (t, fdNumber, generator, input, objectMode, isInput) => {13- const fixtureName = isInput ? 'stdin-fd.js' : 'noop-fd.js';14- const subprocess = execa(fixtureName, [`${fdNumber}`], getStdio(fdNumber, generator(input)(objectMode)));15- const {message} = await t.throwsAsync(subprocess);16- t.true(message.includes(getMessage(input)));17-};18-11 const getMessage = input => {12 if (input === null || input === undefined) {13 return 'not be called at all';14 }7 unmodified lines22 23 const lastInputGenerator = input => objectMode => [foobarUint8Array, getOutputGenerator(input)(objectMode)];24 const inputGenerator = input => objectMode => [...lastInputGenerator(input)(objectMode), serializeGenerator(true)];25 26+// eslint-disable-next-line max-params27+const testGeneratorReturn = async (t, fdNumber, generator, input, objectMode, isInput) => {28+ const fixtureName = isInput ? 'stdin-fd.js' : 'noop-fd.js';29+ const {message} = await t.throwsAsync(execa(fixtureName, [`${fdNumber}`], getStdio(fdNumber, generator(input)(objectMode))));30+ t.true(message.includes(getMessage(input)));31+};32+33 test('Generators with result.stdin cannot return an object if not in objectMode', testGeneratorReturn, 0, inputGenerator, foobarObject, false, true);34 test('Generators with result.stdio[*] as input cannot return an object if not in objectMode', testGeneratorReturn, 3, inputGenerator, foobarObject, false, true);35 test('The last generator with result.stdin cannot return an object even in objectMode', testGeneratorReturn, 0, lastInputGenerator, foobarObject, true, true);36 test('The last generator with result.stdio[*] as input cannot return an object even in objectMode', testGeneratorReturn, 3, lastInputGenerator, foobarObject, true, true);15 unmodified lines52 test('Generators with result.stdin cannot return undefined if in objectMode', testGeneratorReturn, 0, inputGenerator, undefined, true, true);53 test('Generators with result.stdout cannot return undefined if not in objectMode', testGeneratorReturn, 1, getOutputGenerator, undefined, false, false);54 test('Generators with result.stdout cannot return undefined if in objectMode', testGeneratorReturn, 1, getOutputGenerator, undefined, true, false);55 56+// eslint-disable-next-line max-params57+const testGeneratorReturnSync = (t, fdNumber, generator, input, objectMode, isInput) => {58+ const fixtureName = isInput ? 'stdin-fd.js' : 'noop-fd.js';59+ const {message} = t.throws(() => {60+ execaSync(fixtureName, [`${fdNumber}`], getStdio(fdNumber, generator(input)(objectMode)));61+ });62+ t.true(message.includes(getMessage(input)));63+};64+65+test('Generators with result.stdin cannot return an object if not in objectMode, sync', testGeneratorReturnSync, 0, inputGenerator, foobarObject, false, true);66+test('The last generator with result.stdin cannot return an object even in objectMode, sync', testGeneratorReturnSync, 0, lastInputGenerator, foobarObject, true, true);67+test('Generators with result.stdout cannot return an object if not in objectMode, sync', testGeneratorReturnSync, 1, getOutputGenerator, foobarObject, false, false);68+test('Generators with result.stderr cannot return an object if not in objectMode, sync', testGeneratorReturnSync, 2, getOutputGenerator, foobarObject, false, false);69+test('Generators with result.stdio[*] as output cannot return an object if not in objectMode, sync', testGeneratorReturnSync, 3, getOutputGenerator, foobarObject, false, false);70+test('Generators with result.stdin cannot return a Buffer if not in objectMode, sync', testGeneratorReturnSync, 0, inputGenerator, foobarBuffer, false, true);71+test('The last generator with result.stdin cannot return a Buffer even in objectMode, sync', testGeneratorReturnSync, 0, lastInputGenerator, foobarBuffer, true, true);72+test('Generators with result.stdout cannot return a Buffer if not in objectMode, sync', testGeneratorReturnSync, 1, getOutputGenerator, foobarBuffer, false, false);73+test('Generators with result.stderr cannot return a Buffer if not in objectMode, sync', testGeneratorReturnSync, 2, getOutputGenerator, foobarBuffer, false, false);74+test('Generators with result.stdio[*] as output cannot return a Buffer if not in objectMode, sync', testGeneratorReturnSync, 3, getOutputGenerator, foobarBuffer, false, false);75+test('Generators with result.stdin cannot return null if not in objectMode, sync', testGeneratorReturnSync, 0, inputGenerator, null, false, true);76+test('Generators with result.stdin cannot return null if in objectMode, sync', testGeneratorReturnSync, 0, inputGenerator, null, true, true);77+test('Generators with result.stdout cannot return null if not in objectMode, sync', testGeneratorReturnSync, 1, getOutputGenerator, null, false, false);78+test('Generators with result.stdout cannot return null if in objectMode, sync', testGeneratorReturnSync, 1, getOutputGenerator, null, true, false);79+test('Generators with result.stdin cannot return undefined if not in objectMode, sync', testGeneratorReturnSync, 0, inputGenerator, undefined, false, true);80+test('Generators with result.stdin cannot return undefined if in objectMode, sync', testGeneratorReturnSync, 0, inputGenerator, undefined, true, true);81+test('Generators with result.stdout cannot return undefined if not in objectMode, sync', testGeneratorReturnSync, 1, getOutputGenerator, undefined, false, false);82+test('Generators with result.stdout cannot return undefined if in objectMode, sync', testGeneratorReturnSync, 1, getOutputGenerator, undefined, true, false);83+84 test('Generators "final" return value is validated', async t => {58- const subprocess = execa('noop.js', {stdout: convertTransformToFinal(getOutputGenerator(null)(true), true)});59- await t.throwsAsync(subprocess, {message: /not be called at all/});85+ await t.throwsAsync(86+ execa('noop.js', {stdout: convertTransformToFinal(getOutputGenerator(null)(true), true)}),87+ {message: /not be called at all/},88+ );89 });90+91+test('Generators "final" return value is validated, sync', t => {92+ t.throws(() => {93+ execaSync('noop.js', {stdout: convertTransformToFinal(getOutputGenerator(null)(true), true)});94+ }, {message: /not be called at all/});95+});modified:index.d.ts+16 added-15 removed
29 unmodified lines30 | Unless<IsSync, 'overlapped'>;31 32 // @todo Use `string`, `Uint8Array` or `unknown` for both the argument and the return type, based on whether `encoding: 'buffer'` and `objectMode: true` are used.33 // See https://github.com/sindresorhus/execa/issues/69434-type GeneratorTransform = (chunk: unknown) => AsyncGenerator<unknown, void, void> | Generator<unknown, void, void>;35-type GeneratorFinal = () => AsyncGenerator<unknown, void, void> | Generator<unknown, void, void>;34+type GeneratorTransform<IsSync extends boolean> = (chunk: unknown) =>35+| Unless<IsSync, AsyncGenerator<unknown, void, void>>36+| Generator<unknown, void, void>;37+type GeneratorFinal<IsSync extends boolean> = () =>38+| Unless<IsSync, AsyncGenerator<unknown, void, void>>39+| Generator<unknown, void, void>;40 37-type GeneratorTransformFull = {38- transform: GeneratorTransform;39- final?: GeneratorFinal;41+type GeneratorTransformFull<IsSync extends boolean> = {42+ transform: GeneratorTransform<IsSync>;43+ final?: GeneratorFinal<IsSync>;44 binary?: boolean;45 preserveNewlines?: boolean;46 objectMode?: boolean;47 };14 unmodified lines62 > =63 | BaseStdioOption<IsSync, IsArray>64 | URL65 | {file: string}66+ | GeneratorTransform<IsSync>67+ | GeneratorTransformFull<IsSync>68 | Unless<And<IsSync, IsArray>, number>69 | Unless<Or<IsSync, IsArray>, 'ipc'>70 | Unless<IsSync,65- | GeneratorTransform66- | GeneratorTransformFull71 | DuplexTransform72 | WebTransform73 | TransformStream>;74 75 // Synchronous iterables excluding strings, Uint8Arrays and Arrays72-type IterableObject<73- IsSync extends boolean = boolean,74- IsArray extends boolean = boolean,75-> = Iterable<Unless<IsSync, unknown, string | Uint8Array>>76+type IterableObject<IsArray extends boolean = boolean> = Iterable<unknown>77 & object78 & {readonly BYTES_PER_ELEMENT?: never}79 & AndUnless<IsArray, {readonly lastIndexOf?: never}>;80 1 unmodified line82 IsSync extends boolean = boolean,83 IsExtra extends boolean = boolean,84 IsArray extends boolean = boolean,85 > =85- | Unless<And<IsSync, IsExtra>, Uint8Array | IterableObject<IsSync, IsArray>>86+ | Unless<And<IsSync, IsExtra>, Uint8Array | IterableObject<IsArray>>87 | Unless<And<IsSync, IsArray>, Readable>88 | Unless<IsSync, AsyncIterable<unknown> | ReadableStream>;89 90 type OutputStdioOption<90 unmodified lines181 ? OutputOptions[number]182 : OutputOptions183 >;184 184-type IsObjectOutputOption<OutputOption extends StdioSingleOption> = OutputOption extends GeneratorTransformFull | WebTransform185+type IsObjectOutputOption<OutputOption extends StdioSingleOption> = OutputOption extends GeneratorTransformFull<boolean> | WebTransform186 ? BooleanObjectMode<OutputOption['objectMode']>187 : OutputOption extends DuplexTransform188 ? DuplexObjectMode<OutputOption>189 : false;1212 unmodified lines1402 Same as `execa()` but synchronous.1403 1404 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.1405 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+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 async transform, a `Duplex`, or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1407 1408 @param file - The program/script to execute, as a string or file URL1409 @param arguments - Arguments to pass to `file` on execution.1410 @returns A `subprocessResult` object105 unmodified lines1516 Same as `execaCommand()` but synchronous.1517 1518 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.1519 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+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 async transform, a `Duplex`, or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1521 1522 @param command - The program/script to execute and its arguments.1523 @returns A `subprocessResult` object1524 @throws A `subprocessResult` error128 unmodified linesmodified:index.test-d.ts+137 added-137 removed
160 unmodified lines161 const preserveNewlinesOnly = {preserveNewlines: true} as const;162 const objectModeOnly = {objectMode: true} as const;163 const finalOnly = {final: unknownFinal} as const;164 165-type AnySyncChunk = string | Uint8Array | undefined;166-type AnyChunk = AnySyncChunk | string[] | unknown[];165+type AnySyncChunk = string | Uint8Array | unknown[] | undefined;166+type AnyChunk = AnySyncChunk | string[];167 expectType<Writable | null>({} as ExecaSubprocess['stdin']);168 expectType<Readable | null>({} as ExecaSubprocess['stdout']);169 expectType<Readable | null>({} as ExecaSubprocess['stderr']);170 expectType<Readable | undefined>({} as ExecaSubprocess['all']);1872 unmodified lines2043 expectNotAssignable<StdoutStderrOptionSync>([binaryArray]);2044 expectAssignable<StdioOption>([binaryArray]);2045 expectAssignable<StdioOptionSync>([binaryArray]);2046 execa('unicorns', {stdin: [objectArray]});2047-expectError(execaSync('unicorns', {stdin: [objectArray]}));2047+execaSync('unicorns', {stdin: [objectArray]});2048 expectError(execa('unicorns', {stdout: [objectArray]}));2049 expectError(execaSync('unicorns', {stdout: [objectArray]}));2050 expectError(execa('unicorns', {stderr: [objectArray]}));2051 expectError(execaSync('unicorns', {stderr: [objectArray]}));1 unmodified line2053 expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectArray]]}));2054 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [[objectArray]]]});2055 expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [[objectArray]]]}));2056 expectAssignable<StdinOption>([objectArray]);2057-expectNotAssignable<StdinOptionSync>([objectArray]);2057+expectAssignable<StdinOptionSync>([objectArray]);2058 expectNotAssignable<StdoutStderrOption>([objectArray]);2059 expectNotAssignable<StdoutStderrOptionSync>([objectArray]);2060 expectAssignable<StdioOption>([objectArray]);2061-expectNotAssignable<StdioOptionSync>([objectArray]);2061+expectAssignable<StdioOptionSync>([objectArray]);2062 execa('unicorns', {stdin: stringIterable});2063 execaSync('unicorns', {stdin: stringIterable});2064 execa('unicorns', {stdin: [stringIterable]});2065 execaSync('unicorns', {stdin: [stringIterable]});53 unmodified lines2119 expectAssignable<StdioOptionSync>(binaryIterable);2120 expectAssignable<StdioOption>([binaryIterable]);2121 expectAssignable<StdioOptionSync>([binaryIterable]);2122 execa('unicorns', {stdin: objectIterable});2123-expectError(execaSync('unicorns', {stdin: objectIterable}));2123+execaSync('unicorns', {stdin: objectIterable});2124 execa('unicorns', {stdin: [objectIterable]});2125-expectError(execaSync('unicorns', {stdin: [objectIterable]}));2125+execaSync('unicorns', {stdin: [objectIterable]});2126 expectError(execa('unicorns', {stdout: objectIterable}));2127 expectError(execaSync('unicorns', {stdout: objectIterable}));2128 expectError(execa('unicorns', {stdout: [objectIterable]}));2129 expectError(execaSync('unicorns', {stdout: [objectIterable]}));7 unmodified lines2137 expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectIterable]}));2138 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectIterable]]});2139 expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectIterable]]}));2140 expectAssignable<StdinOption>(objectIterable);2141-expectNotAssignable<StdinOptionSync>(objectIterable);2141+expectAssignable<StdinOptionSync>(objectIterable);2142 expectAssignable<StdinOption>([objectIterable]);2143-expectNotAssignable<StdinOptionSync>([objectIterable]);2143+expectAssignable<StdinOptionSync>([objectIterable]);2144 expectNotAssignable<StdoutStderrOption>(objectIterable);2145 expectNotAssignable<StdoutStderrOptionSync>(objectIterable);2146 expectNotAssignable<StdoutStderrOption>([objectIterable]);2147 expectNotAssignable<StdoutStderrOptionSync>([objectIterable]);2148 expectAssignable<StdioOption>(objectIterable);2149-expectNotAssignable<StdioOptionSync>(objectIterable);2149+expectAssignable<StdioOptionSync>(objectIterable);2150 expectAssignable<StdioOption>([objectIterable]);2151-expectNotAssignable<StdioOptionSync>([objectIterable]);2151+expectAssignable<StdioOptionSync>([objectIterable]);2152 execa('unicorns', {stdin: asyncStringIterable});2153 expectError(execaSync('unicorns', {stdin: asyncStringIterable}));2154 execa('unicorns', {stdin: [asyncStringIterable]});2155 expectError(execaSync('unicorns', {stdin: [asyncStringIterable]}));323 unmodified lines2479 expectNotAssignable<StdioOptionSync>(webTransformWithInvalidObjectMode);2480 expectNotAssignable<StdioOption>([webTransformWithInvalidObjectMode]);2481 expectNotAssignable<StdioOptionSync>([webTransformWithInvalidObjectMode]);2482 execa('unicorns', {stdin: unknownGenerator});2483-expectError(execaSync('unicorns', {stdin: unknownGenerator}));2483+execaSync('unicorns', {stdin: unknownGenerator});2484 execa('unicorns', {stdin: [unknownGenerator]});2485-expectError(execaSync('unicorns', {stdin: [unknownGenerator]}));2485+execaSync('unicorns', {stdin: [unknownGenerator]});2486 execa('unicorns', {stdout: unknownGenerator});2487-expectError(execaSync('unicorns', {stdout: unknownGenerator}));2487+execaSync('unicorns', {stdout: unknownGenerator});2488 execa('unicorns', {stdout: [unknownGenerator]});2489-expectError(execaSync('unicorns', {stdout: [unknownGenerator]}));2489+execaSync('unicorns', {stdout: [unknownGenerator]});2490 execa('unicorns', {stderr: unknownGenerator});2491-expectError(execaSync('unicorns', {stderr: unknownGenerator}));2491+execaSync('unicorns', {stderr: unknownGenerator});2492 execa('unicorns', {stderr: [unknownGenerator]});2493-expectError(execaSync('unicorns', {stderr: [unknownGenerator]}));2493+execaSync('unicorns', {stderr: [unknownGenerator]});2494 expectError(execa('unicorns', {stdio: unknownGenerator}));2495 expectError(execaSync('unicorns', {stdio: unknownGenerator}));2496 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', unknownGenerator]});2497-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', unknownGenerator]}));2497+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', unknownGenerator]});2498 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [unknownGenerator]]});2499-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [unknownGenerator]]}));2499+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [unknownGenerator]]});2500 expectAssignable<StdinOption>(unknownGenerator);2501-expectNotAssignable<StdinOptionSync>(unknownGenerator);2501+expectAssignable<StdinOptionSync>(unknownGenerator);2502 expectAssignable<StdinOption>([unknownGenerator]);2503-expectNotAssignable<StdinOptionSync>([unknownGenerator]);2503+expectAssignable<StdinOptionSync>([unknownGenerator]);2504 expectAssignable<StdoutStderrOption>(unknownGenerator);2505-expectNotAssignable<StdoutStderrOptionSync>(unknownGenerator);2505+expectAssignable<StdoutStderrOptionSync>(unknownGenerator);2506 expectAssignable<StdoutStderrOption>([unknownGenerator]);2507-expectNotAssignable<StdoutStderrOptionSync>([unknownGenerator]);2507+expectAssignable<StdoutStderrOptionSync>([unknownGenerator]);2508 expectAssignable<StdioOption>(unknownGenerator);2509-expectNotAssignable<StdioOptionSync>(unknownGenerator);2509+expectAssignable<StdioOptionSync>(unknownGenerator);2510 expectAssignable<StdioOption>([unknownGenerator]);2511-expectNotAssignable<StdioOptionSync>([unknownGenerator]);2511+expectAssignable<StdioOptionSync>([unknownGenerator]);2512 execa('unicorns', {stdin: unknownGeneratorFull});2513-expectError(execaSync('unicorns', {stdin: unknownGeneratorFull}));2513+execaSync('unicorns', {stdin: unknownGeneratorFull});2514 execa('unicorns', {stdin: [unknownGeneratorFull]});2515-expectError(execaSync('unicorns', {stdin: [unknownGeneratorFull]}));2515+execaSync('unicorns', {stdin: [unknownGeneratorFull]});2516 execa('unicorns', {stdout: unknownGeneratorFull});2517-expectError(execaSync('unicorns', {stdout: unknownGeneratorFull}));2517+execaSync('unicorns', {stdout: unknownGeneratorFull});2518 execa('unicorns', {stdout: [unknownGeneratorFull]});2519-expectError(execaSync('unicorns', {stdout: [unknownGeneratorFull]}));2519+execaSync('unicorns', {stdout: [unknownGeneratorFull]});2520 execa('unicorns', {stderr: unknownGeneratorFull});2521-expectError(execaSync('unicorns', {stderr: unknownGeneratorFull}));2521+execaSync('unicorns', {stderr: unknownGeneratorFull});2522 execa('unicorns', {stderr: [unknownGeneratorFull]});2523-expectError(execaSync('unicorns', {stderr: [unknownGeneratorFull]}));2523+execaSync('unicorns', {stderr: [unknownGeneratorFull]});2524 expectError(execa('unicorns', {stdio: unknownGeneratorFull}));2525 expectError(execaSync('unicorns', {stdio: unknownGeneratorFull}));2526 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', unknownGeneratorFull]});2527-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', unknownGeneratorFull]}));2527+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', unknownGeneratorFull]});2528 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [unknownGeneratorFull]]});2529-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [unknownGeneratorFull]]}));2529+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [unknownGeneratorFull]]});2530 expectAssignable<StdinOption>(unknownGeneratorFull);2531-expectNotAssignable<StdinOptionSync>(unknownGeneratorFull);2531+expectAssignable<StdinOptionSync>(unknownGeneratorFull);2532 expectAssignable<StdinOption>([unknownGeneratorFull]);2533-expectNotAssignable<StdinOptionSync>([unknownGeneratorFull]);2533+expectAssignable<StdinOptionSync>([unknownGeneratorFull]);2534 expectAssignable<StdoutStderrOption>(unknownGeneratorFull);2535-expectNotAssignable<StdoutStderrOptionSync>(unknownGeneratorFull);2535+expectAssignable<StdoutStderrOptionSync>(unknownGeneratorFull);2536 expectAssignable<StdoutStderrOption>([unknownGeneratorFull]);2537-expectNotAssignable<StdoutStderrOptionSync>([unknownGeneratorFull]);2537+expectAssignable<StdoutStderrOptionSync>([unknownGeneratorFull]);2538 expectAssignable<StdioOption>(unknownGeneratorFull);2539-expectNotAssignable<StdioOptionSync>(unknownGeneratorFull);2539+expectAssignable<StdioOptionSync>(unknownGeneratorFull);2540 expectAssignable<StdioOption>([unknownGeneratorFull]);2541-expectNotAssignable<StdioOptionSync>([unknownGeneratorFull]);2541+expectAssignable<StdioOptionSync>([unknownGeneratorFull]);2542 execa('unicorns', {stdin: unknownFinalFull});2543-expectError(execaSync('unicorns', {stdin: unknownFinalFull}));2543+execaSync('unicorns', {stdin: unknownFinalFull});2544 execa('unicorns', {stdin: [unknownFinalFull]});2545-expectError(execaSync('unicorns', {stdin: [unknownFinalFull]}));2545+execaSync('unicorns', {stdin: [unknownFinalFull]});2546 execa('unicorns', {stdout: unknownFinalFull});2547-expectError(execaSync('unicorns', {stdout: unknownFinalFull}));2547+execaSync('unicorns', {stdout: unknownFinalFull});2548 execa('unicorns', {stdout: [unknownFinalFull]});2549-expectError(execaSync('unicorns', {stdout: [unknownFinalFull]}));2549+execaSync('unicorns', {stdout: [unknownFinalFull]});2550 execa('unicorns', {stderr: unknownFinalFull});2551-expectError(execaSync('unicorns', {stderr: unknownFinalFull}));2551+execaSync('unicorns', {stderr: unknownFinalFull});2552 execa('unicorns', {stderr: [unknownFinalFull]});2553-expectError(execaSync('unicorns', {stderr: [unknownFinalFull]}));2553+execaSync('unicorns', {stderr: [unknownFinalFull]});2554 expectError(execa('unicorns', {stdio: unknownFinalFull}));2555 expectError(execaSync('unicorns', {stdio: unknownFinalFull}));2556 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', unknownFinalFull]});2557-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', unknownFinalFull]}));2557+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', unknownFinalFull]});2558 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [unknownFinalFull]]});2559-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [unknownFinalFull]]}));2559+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [unknownFinalFull]]});2560 expectAssignable<StdinOption>(unknownFinalFull);2561-expectNotAssignable<StdinOptionSync>(unknownFinalFull);2561+expectAssignable<StdinOptionSync>(unknownFinalFull);2562 expectAssignable<StdinOption>([unknownFinalFull]);2563-expectNotAssignable<StdinOptionSync>([unknownFinalFull]);2563+expectAssignable<StdinOptionSync>([unknownFinalFull]);2564 expectAssignable<StdoutStderrOption>(unknownFinalFull);2565-expectNotAssignable<StdoutStderrOptionSync>(unknownFinalFull);2565+expectAssignable<StdoutStderrOptionSync>(unknownFinalFull);2566 expectAssignable<StdoutStderrOption>([unknownFinalFull]);2567-expectNotAssignable<StdoutStderrOptionSync>([unknownFinalFull]);2567+expectAssignable<StdoutStderrOptionSync>([unknownFinalFull]);2568 expectAssignable<StdioOption>(unknownFinalFull);2569-expectNotAssignable<StdioOptionSync>(unknownFinalFull);2569+expectAssignable<StdioOptionSync>(unknownFinalFull);2570 expectAssignable<StdioOption>([unknownFinalFull]);2571-expectNotAssignable<StdioOptionSync>([unknownFinalFull]);2571+expectAssignable<StdioOptionSync>([unknownFinalFull]);2572 execa('unicorns', {stdin: objectGenerator});2573-expectError(execaSync('unicorns', {stdin: objectGenerator}));2573+execaSync('unicorns', {stdin: objectGenerator});2574 execa('unicorns', {stdin: [objectGenerator]});2575-expectError(execaSync('unicorns', {stdin: [objectGenerator]}));2575+execaSync('unicorns', {stdin: [objectGenerator]});2576 execa('unicorns', {stdout: objectGenerator});2577-expectError(execaSync('unicorns', {stdout: objectGenerator}));2577+execaSync('unicorns', {stdout: objectGenerator});2578 execa('unicorns', {stdout: [objectGenerator]});2579-expectError(execaSync('unicorns', {stdout: [objectGenerator]}));2579+execaSync('unicorns', {stdout: [objectGenerator]});2580 execa('unicorns', {stderr: objectGenerator});2581-expectError(execaSync('unicorns', {stderr: objectGenerator}));2581+execaSync('unicorns', {stderr: objectGenerator});2582 execa('unicorns', {stderr: [objectGenerator]});2583-expectError(execaSync('unicorns', {stderr: [objectGenerator]}));2583+execaSync('unicorns', {stderr: [objectGenerator]});2584 expectError(execa('unicorns', {stdio: objectGenerator}));2585 expectError(execaSync('unicorns', {stdio: objectGenerator}));2586 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectGenerator]});2587-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectGenerator]}));2587+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectGenerator]});2588 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectGenerator]]});2589-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectGenerator]]}));2589+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectGenerator]]});2590 expectAssignable<StdinOption>(objectGenerator);2591-expectNotAssignable<StdinOptionSync>(objectGenerator);2591+expectAssignable<StdinOptionSync>(objectGenerator);2592 expectAssignable<StdinOption>([objectGenerator]);2593-expectNotAssignable<StdinOptionSync>([objectGenerator]);2593+expectAssignable<StdinOptionSync>([objectGenerator]);2594 expectAssignable<StdoutStderrOption>(objectGenerator);2595-expectNotAssignable<StdoutStderrOptionSync>(objectGenerator);2595+expectAssignable<StdoutStderrOptionSync>(objectGenerator);2596 expectAssignable<StdoutStderrOption>([objectGenerator]);2597-expectNotAssignable<StdoutStderrOptionSync>([objectGenerator]);2597+expectAssignable<StdoutStderrOptionSync>([objectGenerator]);2598 expectAssignable<StdioOption>(objectGenerator);2599-expectNotAssignable<StdioOptionSync>(objectGenerator);2599+expectAssignable<StdioOptionSync>(objectGenerator);2600 expectAssignable<StdioOption>([objectGenerator]);2601-expectNotAssignable<StdioOptionSync>([objectGenerator]);2601+expectAssignable<StdioOptionSync>([objectGenerator]);2602 execa('unicorns', {stdin: objectGeneratorFull});2603-expectError(execaSync('unicorns', {stdin: objectGeneratorFull}));2603+execaSync('unicorns', {stdin: objectGeneratorFull});2604 execa('unicorns', {stdin: [objectGeneratorFull]});2605-expectError(execaSync('unicorns', {stdin: [objectGeneratorFull]}));2605+execaSync('unicorns', {stdin: [objectGeneratorFull]});2606 execa('unicorns', {stdout: objectGeneratorFull});2607-expectError(execaSync('unicorns', {stdout: objectGeneratorFull}));2607+execaSync('unicorns', {stdout: objectGeneratorFull});2608 execa('unicorns', {stdout: [objectGeneratorFull]});2609-expectError(execaSync('unicorns', {stdout: [objectGeneratorFull]}));2609+execaSync('unicorns', {stdout: [objectGeneratorFull]});2610 execa('unicorns', {stderr: objectGeneratorFull});2611-expectError(execaSync('unicorns', {stderr: objectGeneratorFull}));2611+execaSync('unicorns', {stderr: objectGeneratorFull});2612 execa('unicorns', {stderr: [objectGeneratorFull]});2613-expectError(execaSync('unicorns', {stderr: [objectGeneratorFull]}));2613+execaSync('unicorns', {stderr: [objectGeneratorFull]});2614 expectError(execa('unicorns', {stdio: objectGeneratorFull}));2615 expectError(execaSync('unicorns', {stdio: objectGeneratorFull}));2616 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectGeneratorFull]});2617-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectGeneratorFull]}));2617+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectGeneratorFull]});2618 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectGeneratorFull]]});2619-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectGeneratorFull]]}));2619+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectGeneratorFull]]});2620 expectAssignable<StdinOption>(objectGeneratorFull);2621-expectNotAssignable<StdinOptionSync>(objectGeneratorFull);2621+expectAssignable<StdinOptionSync>(objectGeneratorFull);2622 expectAssignable<StdinOption>([objectGeneratorFull]);2623-expectNotAssignable<StdinOptionSync>([objectGeneratorFull]);2623+expectAssignable<StdinOptionSync>([objectGeneratorFull]);2624 expectAssignable<StdoutStderrOption>(objectGeneratorFull);2625-expectNotAssignable<StdoutStderrOptionSync>(objectGeneratorFull);2625+expectAssignable<StdoutStderrOptionSync>(objectGeneratorFull);2626 expectAssignable<StdoutStderrOption>([objectGeneratorFull]);2627-expectNotAssignable<StdoutStderrOptionSync>([objectGeneratorFull]);2627+expectAssignable<StdoutStderrOptionSync>([objectGeneratorFull]);2628 expectAssignable<StdioOption>(objectGeneratorFull);2629-expectNotAssignable<StdioOptionSync>(objectGeneratorFull);2629+expectAssignable<StdioOptionSync>(objectGeneratorFull);2630 expectAssignable<StdioOption>([objectGeneratorFull]);2631-expectNotAssignable<StdioOptionSync>([objectGeneratorFull]);2631+expectAssignable<StdioOptionSync>([objectGeneratorFull]);2632 execa('unicorns', {stdin: objectFinalFull});2633-expectError(execaSync('unicorns', {stdin: objectFinalFull}));2633+execaSync('unicorns', {stdin: objectFinalFull});2634 execa('unicorns', {stdin: [objectFinalFull]});2635-expectError(execaSync('unicorns', {stdin: [objectFinalFull]}));2635+execaSync('unicorns', {stdin: [objectFinalFull]});2636 execa('unicorns', {stdout: objectFinalFull});2637-expectError(execaSync('unicorns', {stdout: objectFinalFull}));2637+execaSync('unicorns', {stdout: objectFinalFull});2638 execa('unicorns', {stdout: [objectFinalFull]});2639-expectError(execaSync('unicorns', {stdout: [objectFinalFull]}));2639+execaSync('unicorns', {stdout: [objectFinalFull]});2640 execa('unicorns', {stderr: objectFinalFull});2641-expectError(execaSync('unicorns', {stderr: objectFinalFull}));2641+execaSync('unicorns', {stderr: objectFinalFull});2642 execa('unicorns', {stderr: [objectFinalFull]});2643-expectError(execaSync('unicorns', {stderr: [objectFinalFull]}));2643+execaSync('unicorns', {stderr: [objectFinalFull]});2644 expectError(execa('unicorns', {stdio: objectFinalFull}));2645 expectError(execaSync('unicorns', {stdio: objectFinalFull}));2646 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectFinalFull]});2647-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectFinalFull]}));2647+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectFinalFull]});2648 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectFinalFull]]});2649-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectFinalFull]]}));2649+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectFinalFull]]});2650 expectAssignable<StdinOption>(objectFinalFull);2651-expectNotAssignable<StdinOptionSync>(objectFinalFull);2651+expectAssignable<StdinOptionSync>(objectFinalFull);2652 expectAssignable<StdinOption>([objectFinalFull]);2653-expectNotAssignable<StdinOptionSync>([objectFinalFull]);2653+expectAssignable<StdinOptionSync>([objectFinalFull]);2654 expectAssignable<StdoutStderrOption>(objectFinalFull);2655-expectNotAssignable<StdoutStderrOptionSync>(objectFinalFull);2655+expectAssignable<StdoutStderrOptionSync>(objectFinalFull);2656 expectAssignable<StdoutStderrOption>([objectFinalFull]);2657-expectNotAssignable<StdoutStderrOptionSync>([objectFinalFull]);2657+expectAssignable<StdoutStderrOptionSync>([objectFinalFull]);2658 expectAssignable<StdioOption>(objectFinalFull);2659-expectNotAssignable<StdioOptionSync>(objectFinalFull);2659+expectAssignable<StdioOptionSync>(objectFinalFull);2660 expectAssignable<StdioOption>([objectFinalFull]);2661-expectNotAssignable<StdioOptionSync>([objectFinalFull]);2661+expectAssignable<StdioOptionSync>([objectFinalFull]);2662 expectError(execa('unicorns', {stdin: booleanGenerator}));2663 expectError(execaSync('unicorns', {stdin: booleanGenerator}));2664 expectError(execa('unicorns', {stdin: [booleanGenerator]}));2665 expectError(execaSync('unicorns', {stdin: [booleanGenerator]}));293 unmodified lines2959 expectNotAssignable<StdioOptionSync>(invalidReturnFinalFull);2960 expectNotAssignable<StdioOption>([invalidReturnFinalFull]);2961 expectNotAssignable<StdioOptionSync>([invalidReturnFinalFull]);2962 execa('unicorns', {stdin: transformWithBinary});2963-expectError(execaSync('unicorns', {stdin: transformWithBinary}));2963+execaSync('unicorns', {stdin: transformWithBinary});2964 execa('unicorns', {stdin: [transformWithBinary]});2965-expectError(execaSync('unicorns', {stdin: [transformWithBinary]}));2965+execaSync('unicorns', {stdin: [transformWithBinary]});2966 execa('unicorns', {stdout: transformWithBinary});2967-expectError(execaSync('unicorns', {stdout: transformWithBinary}));2967+execaSync('unicorns', {stdout: transformWithBinary});2968 execa('unicorns', {stdout: [transformWithBinary]});2969-expectError(execaSync('unicorns', {stdout: [transformWithBinary]}));2969+execaSync('unicorns', {stdout: [transformWithBinary]});2970 execa('unicorns', {stderr: transformWithBinary});2971-expectError(execaSync('unicorns', {stderr: transformWithBinary}));2971+execaSync('unicorns', {stderr: transformWithBinary});2972 execa('unicorns', {stderr: [transformWithBinary]});2973-expectError(execaSync('unicorns', {stderr: [transformWithBinary]}));2973+execaSync('unicorns', {stderr: [transformWithBinary]});2974 expectError(execa('unicorns', {stdio: transformWithBinary}));2975 expectError(execaSync('unicorns', {stdio: transformWithBinary}));2976 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithBinary]});2977-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithBinary]}));2977+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithBinary]});2978 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithBinary]]});2979-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithBinary]]}));2979+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithBinary]]});2980 expectAssignable<StdinOption>(transformWithBinary);2981-expectNotAssignable<StdinOptionSync>(transformWithBinary);2981+expectAssignable<StdinOptionSync>(transformWithBinary);2982 expectAssignable<StdinOption>([transformWithBinary]);2983-expectNotAssignable<StdinOptionSync>([transformWithBinary]);2983+expectAssignable<StdinOptionSync>([transformWithBinary]);2984 expectAssignable<StdoutStderrOption>(transformWithBinary);2985-expectNotAssignable<StdoutStderrOptionSync>(transformWithBinary);2985+expectAssignable<StdoutStderrOptionSync>(transformWithBinary);2986 expectAssignable<StdoutStderrOption>([transformWithBinary]);2987-expectNotAssignable<StdoutStderrOptionSync>([transformWithBinary]);2987+expectAssignable<StdoutStderrOptionSync>([transformWithBinary]);2988 expectAssignable<StdioOption>(transformWithBinary);2989-expectNotAssignable<StdioOptionSync>(transformWithBinary);2989+expectAssignable<StdioOptionSync>(transformWithBinary);2990 expectAssignable<StdioOption>([transformWithBinary]);2991-expectNotAssignable<StdioOptionSync>([transformWithBinary]);2991+expectAssignable<StdioOptionSync>([transformWithBinary]);2992 expectError(execa('unicorns', {stdin: transformWithInvalidBinary}));2993 expectError(execaSync('unicorns', {stdin: transformWithInvalidBinary}));2994 expectError(execa('unicorns', {stdin: [transformWithInvalidBinary]}));2995 expectError(execaSync('unicorns', {stdin: [transformWithInvalidBinary]}));23 unmodified lines3019 expectNotAssignable<StdioOptionSync>(transformWithInvalidBinary);3020 expectNotAssignable<StdioOption>([transformWithInvalidBinary]);3021 expectNotAssignable<StdioOptionSync>([transformWithInvalidBinary]);3022 execa('unicorns', {stdin: transformWithPreserveNewlines});3023-expectError(execaSync('unicorns', {stdin: transformWithPreserveNewlines}));3023+execaSync('unicorns', {stdin: transformWithPreserveNewlines});3024 execa('unicorns', {stdin: [transformWithPreserveNewlines]});3025-expectError(execaSync('unicorns', {stdin: [transformWithPreserveNewlines]}));3025+execaSync('unicorns', {stdin: [transformWithPreserveNewlines]});3026 execa('unicorns', {stdout: transformWithPreserveNewlines});3027-expectError(execaSync('unicorns', {stdout: transformWithPreserveNewlines}));3027+execaSync('unicorns', {stdout: transformWithPreserveNewlines});3028 execa('unicorns', {stdout: [transformWithPreserveNewlines]});3029-expectError(execaSync('unicorns', {stdout: [transformWithPreserveNewlines]}));3029+execaSync('unicorns', {stdout: [transformWithPreserveNewlines]});3030 execa('unicorns', {stderr: transformWithPreserveNewlines});3031-expectError(execaSync('unicorns', {stderr: transformWithPreserveNewlines}));3031+execaSync('unicorns', {stderr: transformWithPreserveNewlines});3032 execa('unicorns', {stderr: [transformWithPreserveNewlines]});3033-expectError(execaSync('unicorns', {stderr: [transformWithPreserveNewlines]}));3033+execaSync('unicorns', {stderr: [transformWithPreserveNewlines]});3034 expectError(execa('unicorns', {stdio: transformWithPreserveNewlines}));3035 expectError(execaSync('unicorns', {stdio: transformWithPreserveNewlines}));3036 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithPreserveNewlines]});3037-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithPreserveNewlines]}));3037+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithPreserveNewlines]});3038 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithPreserveNewlines]]});3039-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithPreserveNewlines]]}));3039+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithPreserveNewlines]]});3040 expectAssignable<StdinOption>(transformWithPreserveNewlines);3041-expectNotAssignable<StdinOptionSync>(transformWithPreserveNewlines);3041+expectAssignable<StdinOptionSync>(transformWithPreserveNewlines);3042 expectAssignable<StdinOption>([transformWithPreserveNewlines]);3043-expectNotAssignable<StdinOptionSync>([transformWithPreserveNewlines]);3043+expectAssignable<StdinOptionSync>([transformWithPreserveNewlines]);3044 expectAssignable<StdoutStderrOption>(transformWithPreserveNewlines);3045-expectNotAssignable<StdoutStderrOptionSync>(transformWithPreserveNewlines);3045+expectAssignable<StdoutStderrOptionSync>(transformWithPreserveNewlines);3046 expectAssignable<StdoutStderrOption>([transformWithPreserveNewlines]);3047-expectNotAssignable<StdoutStderrOptionSync>([transformWithPreserveNewlines]);3047+expectAssignable<StdoutStderrOptionSync>([transformWithPreserveNewlines]);3048 expectAssignable<StdioOption>(transformWithPreserveNewlines);3049-expectNotAssignable<StdioOptionSync>(transformWithPreserveNewlines);3049+expectAssignable<StdioOptionSync>(transformWithPreserveNewlines);3050 expectAssignable<StdioOption>([transformWithPreserveNewlines]);3051-expectNotAssignable<StdioOptionSync>([transformWithPreserveNewlines]);3051+expectAssignable<StdioOptionSync>([transformWithPreserveNewlines]);3052 expectError(execa('unicorns', {stdin: transformWithInvalidPreserveNewlines}));3053 expectError(execaSync('unicorns', {stdin: transformWithInvalidPreserveNewlines}));3054 expectError(execa('unicorns', {stdin: [transformWithInvalidPreserveNewlines]}));3055 expectError(execaSync('unicorns', {stdin: [transformWithInvalidPreserveNewlines]}));23 unmodified lines3079 expectNotAssignable<StdioOptionSync>(transformWithInvalidPreserveNewlines);3080 expectNotAssignable<StdioOption>([transformWithInvalidPreserveNewlines]);3081 expectNotAssignable<StdioOptionSync>([transformWithInvalidPreserveNewlines]);3082 execa('unicorns', {stdin: transformWithObjectMode});3083-expectError(execaSync('unicorns', {stdin: transformWithObjectMode}));3083+execaSync('unicorns', {stdin: transformWithObjectMode});3084 execa('unicorns', {stdin: [transformWithObjectMode]});3085-expectError(execaSync('unicorns', {stdin: [transformWithObjectMode]}));3085+execaSync('unicorns', {stdin: [transformWithObjectMode]});3086 execa('unicorns', {stdout: transformWithObjectMode});3087-expectError(execaSync('unicorns', {stdout: transformWithObjectMode}));3087+execaSync('unicorns', {stdout: transformWithObjectMode});3088 execa('unicorns', {stdout: [transformWithObjectMode]});3089-expectError(execaSync('unicorns', {stdout: [transformWithObjectMode]}));3089+execaSync('unicorns', {stdout: [transformWithObjectMode]});3090 execa('unicorns', {stderr: transformWithObjectMode});3091-expectError(execaSync('unicorns', {stderr: transformWithObjectMode}));3091+execaSync('unicorns', {stderr: transformWithObjectMode});3092 execa('unicorns', {stderr: [transformWithObjectMode]});3093-expectError(execaSync('unicorns', {stderr: [transformWithObjectMode]}));3093+execaSync('unicorns', {stderr: [transformWithObjectMode]});3094 expectError(execa('unicorns', {stdio: transformWithObjectMode}));3095 expectError(execaSync('unicorns', {stdio: transformWithObjectMode}));3096 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithObjectMode]});3097-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithObjectMode]}));3097+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithObjectMode]});3098 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithObjectMode]]});3099-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithObjectMode]]}));3099+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithObjectMode]]});3100 expectAssignable<StdinOption>(transformWithObjectMode);3101-expectNotAssignable<StdinOptionSync>(transformWithObjectMode);3101+expectAssignable<StdinOptionSync>(transformWithObjectMode);3102 expectAssignable<StdinOption>([transformWithObjectMode]);3103-expectNotAssignable<StdinOptionSync>([transformWithObjectMode]);3103+expectAssignable<StdinOptionSync>([transformWithObjectMode]);3104 expectAssignable<StdoutStderrOption>(transformWithObjectMode);3105-expectNotAssignable<StdoutStderrOptionSync>(transformWithObjectMode);3105+expectAssignable<StdoutStderrOptionSync>(transformWithObjectMode);3106 expectAssignable<StdoutStderrOption>([transformWithObjectMode]);3107-expectNotAssignable<StdoutStderrOptionSync>([transformWithObjectMode]);3107+expectAssignable<StdoutStderrOptionSync>([transformWithObjectMode]);3108 expectAssignable<StdioOption>(transformWithObjectMode);3109-expectNotAssignable<StdioOptionSync>(transformWithObjectMode);3109+expectAssignable<StdioOptionSync>(transformWithObjectMode);3110 expectAssignable<StdioOption>([transformWithObjectMode]);3111-expectNotAssignable<StdioOptionSync>([transformWithObjectMode]);3111+expectAssignable<StdioOptionSync>([transformWithObjectMode]);3112 expectError(execa('unicorns', {stdin: transformWithInvalidObjectMode}));3113 expectError(execaSync('unicorns', {stdin: transformWithInvalidObjectMode}));3114 expectError(execa('unicorns', {stdin: [transformWithInvalidObjectMode]}));3115 expectError(execaSync('unicorns', {stdin: [transformWithInvalidObjectMode]}));556 unmodified linesmodified:package.json+1 added
65 unmodified lines66 "c8": "^8.0.1",67 "get-node": "^15.0.0",68 "is-running": "^2.1.0",69 "p-event": "^6.0.0",70+ "path-exists": "^5.0.0",71 "path-key": "^4.0.0",72 "tempfile": "^5.0.0",73 "tsd": "^0.29.0",74 "which": "^4.0.0",25 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 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.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 async [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