Add support for `std*: ['pipe', 'inherit']` with `execaSync()` (#954)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent d0052ac · Browse files · 21 files·+466 added−286 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
21 files+466 added−286 removed
- tests:+272 added−148 removed
- other:+194 added−138 removed
Provenance
- Commit
c15edbc- Tree
7d9c690- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
d0052ac
21 files changed+466 added−286 removed
modified:lib/pipe/validate.js+1 added-8 removed
12345678174 unmodified linesExpand all183184185186186187188189190191192193187import {normalizeArguments} from '../arguments/normalize.js';import {STANDARD_STREAMS_ALIASES} from '../utils.js';import {getStartTime} from '../return/duration.js';import {serializeOptionValue} from '../stdio/native.js';
export const normalizePipeArguments = ({source, sourcePromise, boundOptions, createNested}, ...args) => { const startTime = getStartTime(); const {174 unmodified linesExpand all};
const getUsedDescriptor = fdNumber => fdNumber === 'all' ? 1 : fdNumber;
const serializeOptionValue = optionValue => { if (typeof optionValue === 'string') { return `'${optionValue}'`; }
return typeof optionValue === 'number' ? `${optionValue}` : 'Stream';};
const getOptionName = isWritable => isWritable ? 'to' : 'from';modified:lib/stdio/direction.js-5 removed
37 unmodified lines38 asyncIterable: alwaysInput,39 uint8Array: alwaysInput,40 webStream: value => isWritableStream(value) ? 'output' : 'input',41 nodeStream(value) {42- const standardStreamDirection = getStandardStreamDirection(value);43- if (standardStreamDirection !== undefined) {44- return standardStreamDirection;45- }46-42 if (!isNodeReadableStream(value, {checkOpen: false})) {43 return 'output';44 }45 31 unmodified linesmodified:lib/stdio/handle.js+7 added-6 removed
1 import {handleStreamsVerbose} from '../verbose/output.js';2-import {getStdioItemType, isRegularUrl, isUnknownStdioString} from './type.js';2+import {getStdioItemType, isRegularUrl, isUnknownStdioString, FILE_TYPES} from './type.js';3 import {getStreamDirection} from './direction.js';4 import {normalizeStdio} from './option.js';5 import {handleNativeStream} from './native.js';6 import {handleInputOptions} from './input.js';17 unmodified lines24 // For example, `stdout: ['ignore']` behaves the same as `stdout: 'ignore'`.25 const getFileDescriptor = ({stdioOption, fdNumber, addProperties, options, isSync, stdioState, verboseInfo}) => {26 const outputLines = [];27 const optionName = getOptionName(fdNumber);28- const stdioItems = initializeStdioItems({stdioOption, fdNumber, options, isSync, optionName});29- const direction = getStreamDirection(stdioItems, fdNumber, optionName);28+ const {stdioItems: initialStdioItems, isStdioArray} = initializeStdioItems({stdioOption, fdNumber, options, optionName});29+ const direction = getStreamDirection(initialStdioItems, fdNumber, optionName);30+ const stdioItems = initialStdioItems.map(stdioItem => handleNativeStream({stdioItem, isStdioArray, fdNumber, direction, isSync}));31 const objectMode = getObjectMode(stdioItems, optionName, direction, options);32 validateFileObjectMode(stdioItems, objectMode);33 const normalizedStdioItems = normalizeStdioItems({stdioItems, fdNumber, optionName, addProperties, options, isSync, direction, stdioState, verboseInfo, outputLines, objectMode});34 return {fdNumber, direction, outputLines, stdioItems: normalizedStdioItems};1 unmodified line36 37 const getOptionName = fdNumber => KNOWN_OPTION_NAMES[fdNumber] ?? `stdio[${fdNumber}]`;38 const KNOWN_OPTION_NAMES = ['stdin', 'stdout', 'stderr'];39 39-const initializeStdioItems = ({stdioOption, fdNumber, options, isSync, optionName}) => {40+const initializeStdioItems = ({stdioOption, fdNumber, options, optionName}) => {41 const values = Array.isArray(stdioOption) ? stdioOption : [stdioOption];42 const initialStdioItems = [43 ...values.map(value => initializeStdioItem(value, optionName)),44 ...handleInputOptions(options, fdNumber),2 unmodified lines47 const stdioItems = filterDuplicates(initialStdioItems);48 const isStdioArray = stdioItems.length > 1;49 validateStdioArray(stdioItems, isStdioArray, optionName);50 validateStreams(stdioItems);50- return stdioItems.map(stdioItem => handleNativeStream(stdioItem, isStdioArray, fdNumber, isSync));51+ return {stdioItems, isStdioArray};52 };53 54 const initializeStdioItem = (value, optionName) => ({55 type: getStdioItemType(value, optionName),71 unmodified lines127 if (!objectMode) {128 return;129 }130 130- const fileStdioItem = stdioItems.find(({type}) => type === 'fileUrl' || type === 'filePath');131+ const fileStdioItem = stdioItems.find(({type}) => FILE_TYPES.has(type));132 if (fileStdioItem !== undefined) {133 throw new TypeError(`The \`${fileStdioItem.optionName}\` option cannot use both files and transforms in objectMode.`);134 }135 };modified:lib/stdio/native.js+64 added-4 removed
1+import {readFileSync} from 'node:fs';2+import tty from 'node:tty';3 import {isStream as isNodeStream} from 'is-stream';4 import {STANDARD_STREAMS} from '../utils.js';5+import {bufferToUint8Array} from './uint-array.js';6 7 // When we use multiple `stdio` values for the same streams, we pass 'pipe' to `child_process.spawn()`.8 // We then emulate the piping done by core Node.js.9 // To do so, we transform the following values:10 // - Node.js streams are marked as `type: nodeStream`11 // - 'inherit' becomes `process.stdin|stdout|stderr`12 // - any file descriptor integer becomes `process.stdio[fdNumber]`13 // All of the above transformations tell Execa to perform manual piping.11-export const handleNativeStream = (stdioItem, isStdioArray, fdNumber, isSync) => {12- const {type, value, optionName} = stdioItem;13-14- if (!isStdioArray || type !== 'native' || isSync) {14+export const handleNativeStream = ({stdioItem, stdioItem: {type}, isStdioArray, fdNumber, direction, isSync}) => {15+ if (!isStdioArray || type !== 'native') {16 return stdioItem;17 }18 19+ return isSync20+ ? handleNativeStreamSync({stdioItem, fdNumber, direction})21+ : handleNativeStreamAsync({stdioItem, fdNumber});22+};23+24+const handleNativeStreamSync = ({stdioItem, stdioItem: {value, optionName}, fdNumber, direction}) => {25+ const targetFd = getTargetFd({value, optionName, fdNumber, direction});26+ if (targetFd !== undefined) {27+ return targetFd;28+ }29+30+ if (isNodeStream(value, {checkOpen: false})) {31+ throw new TypeError(`The \`${optionName}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);32+ }33+34+ return stdioItem;35+};36+37+const getTargetFd = ({value, optionName, fdNumber, direction}) => {38+ const targetFdNumber = getTargetFdNumber(value, fdNumber);39+ if (targetFdNumber === undefined) {40+ return;41+ }42+43+ if (direction === 'output') {44+ return {type: 'fileNumber', value: targetFdNumber, optionName};45+ }46+47+ if (tty.isatty(targetFdNumber)) {48+ throw new TypeError(`The \`${optionName}: ${serializeOptionValue(value)}\` option is invalid: it cannot be a TTY with synchronous methods.`);49+ }50+51+ return {type: 'uint8Array', value: bufferToUint8Array(readFileSync(targetFdNumber)), optionName};52+};53+54+const getTargetFdNumber = (value, fdNumber) => {55 if (value === 'inherit') {56+ return fdNumber;57+ }58+59+ if (typeof value === 'number') {60+ return value;61+ }62+63+ const standardStreamIndex = STANDARD_STREAMS.indexOf(value);64+ if (standardStreamIndex !== -1) {65+ return standardStreamIndex;66+ }67+};68+69+export const serializeOptionValue = value => {70+ if (typeof value === 'string') {71+ return `'${value}'`;72+ }73+74+ return typeof value === 'number' ? `${value}` : 'Stream';75+};76+77+const handleNativeStreamAsync = ({stdioItem, stdioItem: {value, optionName}, fdNumber}) => {78+ if (value === 'inherit') {79 return {type: 'nodeStream', value: getStandardStream(fdNumber, value, optionName), optionName};80 }81 82 if (typeof value === 'number') {24 unmodified linesmodified:lib/stdio/output-sync.js+4 added-3 removed
1 import {writeFileSync} from 'node:fs';2 import {joinToString, joinToUint8Array, bufferToUint8Array} from './uint-array.js';3 import {getGenerators, runGeneratorsSync} from './generator.js';4+import {FILE_TYPES} from './type.js';5 6 // Apply `stdout`/`stderr` options, after spawning, in sync mode7 export const transformOutputSync = (fileDescriptors, {output}, options) => {8 if (output === null) {50 unmodified lines59 const finalResult = lines ? allOutputLines.flat() : serializedResult;60 return {serializedResult, finalResult};61 };62 62-const writeToFiles = (transformedResult, allStdioItems) => {63+const writeToFiles = (serializedResult, allStdioItems) => {64 for (const {type, path} of allStdioItems) {64- if (type === 'fileUrl' || type === 'filePath') {65- writeFileSync(path, transformedResult);65+ if (FILE_TYPES.has(type)) {66+ writeFileSync(path, serializedResult);67 }68 }69 };modified:lib/stdio/sync.js+2 added-50 removed
1 import {readFileSync} from 'node:fs';2-import {isStream as isNodeStream} from 'is-stream';2 import {bufferToUint8Array} from './uint-array.js';3 import {handleInput} from './handle.js';4 import {TYPE_TO_MESSAGE} from './type.js';5 6 // 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- return fileDescriptors;12-};7+export const handleInputSync = (options, verboseInfo) => handleInput(addPropertiesSync, options, verboseInfo, true);8 9 const forbiddenIfSync = ({type, optionName}) => {10 throwInvalidSyncValue(optionName, TYPE_TO_MESSAGE[type]);11 };33 unmodified lines45 output: {46 ...addProperties,47 fileUrl: ({value}) => ({path: value}),48 filePath: ({value: {file}}) => ({path: file}),49+ fileNumber: ({value}) => ({path: value}),50 iterable: forbiddenIfSync,51 string: forbiddenIfSync,52 uint8Array: forbiddenIfSync,53 },54 };59-60-const validateStdioArraysSync = fileDescriptors => {61- for (const {stdioItems} of fileDescriptors) {62- validateStdioArraySync(stdioItems);63- }64-};65-66-const validateStdioArraySync = stdioItems => {67- if (stdioItems.length === 1) {68- return;69- }70-71- const singleValueName = stdioItems.map(stdioItem => getSingleValueSync(stdioItem)).find(Boolean);72- if (singleValueName === undefined) {73- return;74- }75-76- const inputOption = stdioItems.find(({optionName}) => OPTION_NAMES.has(optionName));77- if (inputOption !== undefined) {78- throw new TypeError(`The \`${singleValueName}\` and the \`${inputOption.optionName}\` options cannot be both set with synchronous methods.`);79- }80-81- throw new TypeError(`The \`${singleValueName}\` option cannot be set as an array of values with synchronous methods.`);82-};83-84-const getSingleValueSync = ({type, value, optionName}) => {85- if (type !== 'native') {86- return;87- }88-89- if (value === 'inherit') {90- return `${optionName}: "inherit"`;91- }92-93- if (typeof value === 'number') {94- return `${optionName}: ${value}`;95- }96-97- if (isNodeStream(value, {checkOpen: false})) {98- return `${optionName}: Stream`;99- }100-};101-102-const OPTION_NAMES = new Set(['input', 'inputFile']);modified:lib/stdio/type.js+2 added
140 unmodified lines141 const isAsyncIterableObject = value => isObject(value) && typeof value[Symbol.asyncIterator] === 'function';142 const isIterableObject = value => isObject(value) && typeof value[Symbol.iterator] === 'function';143 const isObject = value => typeof value === 'object' && value !== null;144 145+export const FILE_TYPES = new Set(['fileUrl', 'filePath', 'fileNumber']);146+147 // Convert types to human-friendly strings for error messages148 export const TYPE_TO_MESSAGE = {149 generator: 'a generator',150 asyncGenerator: 'an async generator',12 unmodified linesmodified:lib/sync.js+1 added-1 removed
19 unmodified lines20 try {21 const syncOptions = normalizeSyncOptions(rawOptions);22 const {file, args, options} = handleOptions(rawFile, rawArgs, syncOptions);23 validateSyncOptions(options);24- const fileDescriptors = handleInputSync(options, verboseInfo);24+ const {fileDescriptors} = handleInputSync(options, verboseInfo);25 return {file, args, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors};26 } catch (error) {27 logEarlyResult(error, startTime, verboseInfo);28 throw error;62 unmodified linesdeleted:test/fixtures/nested-multiple-stderr.js-8 removed
1-#!/usr/bin/env node2-import process from 'node:process';3-import {execa} from '../../index.js';4-import {foobarString} from '../helpers/input.js';5-6-const [options] = process.argv.slice(2);7-const result = await execa('noop-fd.js', ['2', foobarString], {stderr: JSON.parse(options)});8-process.stdout.write(`nested ${result.stderr}`);modified:test/fixtures/nested-multiple-stdin.js+6 added-6 removed
1 #!/usr/bin/env node2 import process from 'node:process';3-import {execa} from '../../index.js';3+import {execa, execaSync} from '../../index.js';4 import {foobarString} from '../helpers/input.js';5+import {parseStdioOption} from '../helpers/stdio.js';6 6-const [options] = process.argv.slice(2);7-const subprocess = execa('stdin.js', {stdin: JSON.parse(options)});8-subprocess.stdin.write(foobarString);9-const {stdout} = await subprocess;10-console.log(stdout);7+const [stdioOption, isSyncString] = process.argv.slice(2);8+const stdin = parseStdioOption(stdioOption);9+const execaMethod = isSyncString === 'true' ? execaSync : execa;10+await execaMethod('stdin.js', {input: foobarString, stdin, stdout: 'inherit'});added:test/fixtures/nested-multiple-stdio-output.js+13 added
1+#!/usr/bin/env node2+import {Buffer} from 'node:buffer';3+import process from 'node:process';4+import {execa, execaSync} from '../../index.js';5+import {foobarString} from '../helpers/input.js';6+import {getStdio, parseStdioOption} from '../helpers/stdio.js';7+import {getWriteStream} from '../helpers/fs.js';8+9+const [stdioOption, fdNumber, outerFdNumber, isSyncString, encoding] = process.argv.slice(2);10+const stdioValue = parseStdioOption(stdioOption);11+const execaMethod = isSyncString === 'true' ? execaSync : execa;12+const {stdio} = await execaMethod('noop-fd.js', [fdNumber, foobarString], {...getStdio(Number(fdNumber), stdioValue), encoding});13+getWriteStream(Number(outerFdNumber)).write(`nested ${Buffer.from(stdio[fdNumber]).toString()}`);deleted:test/fixtures/nested-multiple-stdout.js-8 removed
1-#!/usr/bin/env node2-import process from 'node:process';3-import {execa} from '../../index.js';4-import {foobarString} from '../helpers/input.js';5-6-const [options] = process.argv.slice(2);7-const result = await execa('noop.js', [foobarString], {stdout: JSON.parse(options)});8-process.stderr.write(`nested ${result.stdout}`);modified:test/fixtures/nested-stdio.js+12 added-10 removed
1 #!/usr/bin/env node2 import process from 'node:process';3-import {execa} from '../../index.js';3+import {execa, execaSync} from '../../index.js';4+import {parseStdioOption} from '../helpers/stdio.js';5 5-const [stdioOption, fdNumber, file, ...args] = process.argv.slice(2);6-let optionValue = JSON.parse(stdioOption);7-optionValue = typeof optionValue === 'string' ? process[optionValue] : optionValue;8-optionValue = Array.isArray(optionValue) && typeof optionValue[0] === 'string'9- ? [process[optionValue[0]], ...optionValue.slice(1)]10- : optionValue;6+const [stdioOption, fdNumber, isSyncString, file, ...args] = process.argv.slice(2);7+const optionValue = parseStdioOption(stdioOption);8+const isSync = isSyncString === 'true';9 const stdio = ['ignore', 'inherit', 'inherit'];10 stdio[fdNumber] = optionValue;11+const execaMethod = isSync ? execaSync : execa;13-const subprocess = execa(file, [`${fdNumber}`, ...args], {stdio});12+const returnValue = execaMethod(file, [`${fdNumber}`, ...args], {stdio});13 14 const shouldPipe = Array.isArray(optionValue) && optionValue.includes('pipe');16-const hasPipe = subprocess.stdio[fdNumber] !== null;15+const fdReturnValue = returnValue.stdio[fdNumber];16+const hasPipe = fdReturnValue !== undefined && fdReturnValue !== null;17 18 if (shouldPipe && !hasPipe) {19 throw new Error(`subprocess.stdio[${fdNumber}] is null.`);20 }1 unmodified line22 if (!shouldPipe && hasPipe) {23 throw new Error(`subprocess.stdio[${fdNumber}] should be null.`);24 }25 26-await subprocess;26+if (!isSync) {27+ await returnValue;28+}added:test/fixtures/nested-sync-tty.js+26 added
1+#!/usr/bin/env node2+import process from 'node:process';3+import tty from 'node:tty';4+import {execa, execaSync} from '../../index.js';5+6+const mockIsatty = fdNumber => {7+ tty.isatty = fdNumberArg => fdNumber === fdNumberArg;8+};9+10+const originalIsatty = tty.isatty;11+const unmockIsatty = () => {12+ tty.isatty = originalIsatty;13+};14+15+const [options, isSync, file, fdNumber, ...args] = process.argv.slice(2);16+mockIsatty(Number(fdNumber));17+18+try {19+ if (isSync === 'true') {20+ execaSync(file, [fdNumber, ...args], JSON.parse(options));21+ } else {22+ await execa(file, [fdNumber, ...args], JSON.parse(options));23+ }24+} finally {25+ unmockIsatty();26+}modified:test/helpers/stdio.js+13 added
25 unmodified lines26 if (fdNumber === 1 && !isWindows) {27 t.true(stderr.includes('EPIPE'));28 }29 };30+31+export const parseStdioOption = stdioOption => {32+ const optionValue = JSON.parse(stdioOption);33+ if (typeof optionValue === 'string' && optionValue in process) {34+ return process[optionValue];35+ }36+37+ if (Array.isArray(optionValue) && typeof optionValue[0] === 'string' && optionValue[0] in process) {38+ return [process[optionValue[0]], ...optionValue.slice(1)];39+ }40+41+ return optionValue;42+};modified:test/stdio/native.js+183 added-69 removed
1 import {readFile, rm} from 'node:fs/promises';2 import {platform} from 'node:process';3 import test from 'ava';4 import tempfile from 'tempfile';5-import {execa} from '../../index.js';5+import {execa, execaSync} from '../../index.js';6 import {getStdio, fullStdio} from '../helpers/stdio.js';7 import {setFixtureDir} from '../helpers/fixtures-dir.js';8 import {foobarString} from '../helpers/input.js';9 10 setFixtureDir();11 12+const isLinux = platform === 'linux';13+const isWindows = platform === 'win32';14+15+const getFixtureName = isSync => isSync ? 'nested-sync.js' : 'nested.js';16+17+// eslint-disable-next-line max-params12-const testRedirect = async (t, stdioOption, fdNumber, isInput) => {18+const testRedirect = async (t, stdioOption, fdNumber, isInput, isSync) => {19 const {fixtureName, ...options} = isInput20 ? {fixtureName: 'stdin-fd.js', input: foobarString}21 : {fixtureName: 'noop-fd.js'};16- const {stdio} = await execa('nested-stdio.js', [JSON.stringify(stdioOption), `${fdNumber}`, fixtureName, foobarString], options);22+ const {stdio} = await execa('nested-stdio.js', [JSON.stringify(stdioOption), `${fdNumber}`, `${isSync}`, fixtureName, foobarString], options);23 const resultFdNumber = isStderrDescriptor(stdioOption) ? 2 : 1;24 t.is(stdio[resultFdNumber], foobarString);25 };26 27 const isStderrDescriptor = stdioOption => stdioOption === 228 || stdioOption === 'stderr'29 || (Array.isArray(stdioOption) && isStderrDescriptor(stdioOption[0]));30 25-test.serial('stdio[*] can be 0', testRedirect, 0, 3, true);26-test.serial('stdio[*] can be [0]', testRedirect, [0], 3, true);27-test.serial('stdio[*] can be [0, "pipe"]', testRedirect, [0, 'pipe'], 3, true);28-test.serial('stdio[*] can be process.stdin', testRedirect, 'stdin', 3, true);29-test.serial('stdio[*] can be [process.stdin]', testRedirect, ['stdin'], 3, true);30-test.serial('stdio[*] can be [process.stdin, "pipe"]', testRedirect, ['stdin', 'pipe'], 3, true);31-test('stdout can be 2', testRedirect, 2, 1, false);32-test('stdout can be [2]', testRedirect, [2], 1, false);33-test('stdout can be [2, "pipe"]', testRedirect, [2, 'pipe'], 1, false);34-test('stdout can be process.stderr', testRedirect, 'stderr', 1, false);35-test('stdout can be [process.stderr]', testRedirect, ['stderr'], 1, false);36-test('stdout can be [process.stderr, "pipe"]', testRedirect, ['stderr', 'pipe'], 1, false);37-test('stderr can be 1', testRedirect, 1, 2, false);38-test('stderr can be [1]', testRedirect, [1], 2, false);39-test('stderr can be [1, "pipe"]', testRedirect, [1, 'pipe'], 2, false);40-test('stderr can be process.stdout', testRedirect, 'stdout', 2, false);41-test('stderr can be [process.stdout]', testRedirect, ['stdout'], 2, false);42-test('stderr can be [process.stdout, "pipe"]', testRedirect, ['stdout', 'pipe'], 2, false);43-test('stdio[*] can be 1', testRedirect, 1, 3, false);44-test('stdio[*] can be [1]', testRedirect, [1], 3, false);45-test('stdio[*] can be [1, "pipe"]', testRedirect, [1, 'pipe'], 3, false);46-test('stdio[*] can be 2', testRedirect, 2, 3, false);47-test('stdio[*] can be [2]', testRedirect, [2], 3, false);48-test('stdio[*] can be [2, "pipe"]', testRedirect, [2, 'pipe'], 3, false);49-test('stdio[*] can be process.stdout', testRedirect, 'stdout', 3, false);50-test('stdio[*] can be [process.stdout]', testRedirect, ['stdout'], 3, false);51-test('stdio[*] can be [process.stdout, "pipe"]', testRedirect, ['stdout', 'pipe'], 3, false);52-test('stdio[*] can be process.stderr', testRedirect, 'stderr', 3, false);53-test('stdio[*] can be [process.stderr]', testRedirect, ['stderr'], 3, false);54-test('stdio[*] can be [process.stderr, "pipe"]', testRedirect, ['stderr', 'pipe'], 3, false);31+test.serial('stdio[*] can be 0', testRedirect, 0, 3, true, false);32+test.serial('stdio[*] can be [0]', testRedirect, [0], 3, true, false);33+test.serial('stdio[*] can be [0, "pipe"]', testRedirect, [0, 'pipe'], 3, true, false);34+test.serial('stdio[*] can be process.stdin', testRedirect, 'stdin', 3, true, false);35+test.serial('stdio[*] can be [process.stdin]', testRedirect, ['stdin'], 3, true, false);36+test.serial('stdio[*] can be [process.stdin, "pipe"]', testRedirect, ['stdin', 'pipe'], 3, true, false);37+test('stdout can be 2', testRedirect, 2, 1, false, false);38+test('stdout can be [2]', testRedirect, [2], 1, false, false);39+test('stdout can be [2, "pipe"]', testRedirect, [2, 'pipe'], 1, false, false);40+test('stdout can be process.stderr', testRedirect, 'stderr', 1, false, false);41+test('stdout can be [process.stderr]', testRedirect, ['stderr'], 1, false, false);42+test('stdout can be [process.stderr, "pipe"]', testRedirect, ['stderr', 'pipe'], 1, false, false);43+test('stderr can be 1', testRedirect, 1, 2, false, false);44+test('stderr can be [1]', testRedirect, [1], 2, false, false);45+test('stderr can be [1, "pipe"]', testRedirect, [1, 'pipe'], 2, false, false);46+test('stderr can be process.stdout', testRedirect, 'stdout', 2, false, false);47+test('stderr can be [process.stdout]', testRedirect, ['stdout'], 2, false, false);48+test('stderr can be [process.stdout, "pipe"]', testRedirect, ['stdout', 'pipe'], 2, false, false);49+test('stdio[*] can be 1', testRedirect, 1, 3, false, false);50+test('stdio[*] can be [1]', testRedirect, [1], 3, false, false);51+test('stdio[*] can be [1, "pipe"]', testRedirect, [1, 'pipe'], 3, false, false);52+test('stdio[*] can be 2', testRedirect, 2, 3, false, false);53+test('stdio[*] can be [2]', testRedirect, [2], 3, false, false);54+test('stdio[*] can be [2, "pipe"]', testRedirect, [2, 'pipe'], 3, false, false);55+test('stdio[*] can be process.stdout', testRedirect, 'stdout', 3, false, false);56+test('stdio[*] can be [process.stdout]', testRedirect, ['stdout'], 3, false, false);57+test('stdio[*] can be [process.stdout, "pipe"]', testRedirect, ['stdout', 'pipe'], 3, false, false);58+test('stdio[*] can be process.stderr', testRedirect, 'stderr', 3, false, false);59+test('stdio[*] can be [process.stderr]', testRedirect, ['stderr'], 3, false, false);60+test('stdio[*] can be [process.stderr, "pipe"]', testRedirect, ['stderr', 'pipe'], 3, false, false);61+test('stdout can be 2, sync', testRedirect, 2, 1, false, true);62+test('stdout can be [2], sync', testRedirect, [2], 1, false, true);63+test('stdout can be [2, "pipe"], sync', testRedirect, [2, 'pipe'], 1, false, true);64+test('stdout can be process.stderr, sync', testRedirect, 'stderr', 1, false, true);65+test('stdout can be [process.stderr], sync', testRedirect, ['stderr'], 1, false, true);66+test('stdout can be [process.stderr, "pipe"], sync', testRedirect, ['stderr', 'pipe'], 1, false, true);67+test('stderr can be 1, sync', testRedirect, 1, 2, false, true);68+test('stderr can be [1], sync', testRedirect, [1], 2, false, true);69+test('stderr can be [1, "pipe"], sync', testRedirect, [1, 'pipe'], 2, false, true);70+test('stderr can be process.stdout, sync', testRedirect, 'stdout', 2, false, true);71+test('stderr can be [process.stdout], sync', testRedirect, ['stdout'], 2, false, true);72+test('stderr can be [process.stdout, "pipe"], sync', testRedirect, ['stdout', 'pipe'], 2, false, true);73+test('stdio[*] can be 1, sync', testRedirect, 1, 3, false, true);74+test('stdio[*] can be [1], sync', testRedirect, [1], 3, false, true);75+test('stdio[*] can be [1, "pipe"], sync', testRedirect, [1, 'pipe'], 3, false, true);76+test('stdio[*] can be 2, sync', testRedirect, 2, 3, false, true);77+test('stdio[*] can be [2], sync', testRedirect, [2], 3, false, true);78+test('stdio[*] can be [2, "pipe"], sync', testRedirect, [2, 'pipe'], 3, false, true);79+test('stdio[*] can be process.stdout, sync', testRedirect, 'stdout', 3, false, true);80+test('stdio[*] can be [process.stdout], sync', testRedirect, ['stdout'], 3, false, true);81+test('stdio[*] can be [process.stdout, "pipe"], sync', testRedirect, ['stdout', 'pipe'], 3, false, true);82+test('stdio[*] can be process.stderr, sync', testRedirect, 'stderr', 3, false, true);83+test('stdio[*] can be [process.stderr], sync', testRedirect, ['stderr'], 3, false, true);84+test('stdio[*] can be [process.stderr, "pipe"], sync', testRedirect, ['stderr', 'pipe'], 3, false, true);85 56-const testInheritStdin = async (t, stdin) => {57- const {stdout} = await execa('nested-multiple-stdin.js', [JSON.stringify(stdin)], {input: foobarString});86+const testInheritStdin = async (t, stdioOption, isSync) => {87+ const {stdout} = await execa('nested-multiple-stdin.js', [JSON.stringify(stdioOption), `${isSync}`], {input: foobarString});88 t.is(stdout, `${foobarString}${foobarString}`);89 };90 61-test('stdin can be ["inherit", "pipe"]', testInheritStdin, ['inherit', 'pipe']);62-test('stdin can be [0, "pipe"]', testInheritStdin, [0, 'pipe']);91+test('stdin can be ["inherit", "pipe"]', testInheritStdin, ['inherit', 'pipe'], false);92+test('stdin can be [0, "pipe"]', testInheritStdin, [0, 'pipe'], false);93+test('stdin can be [process.stdin, "pipe"]', testInheritStdin, ['stdin', 'pipe'], false);94+test.serial('stdin can be ["inherit", "pipe"], sync', testInheritStdin, ['inherit', 'pipe'], true);95+test.serial('stdin can be [0, "pipe"], sync', testInheritStdin, [0, 'pipe'], true);96+test.serial('stdin can be [process.stdin, "pipe"], sync', testInheritStdin, ['stdin', 'pipe'], true);97 64-const testInheritStdout = async (t, stdout) => {65- const result = await execa('nested-multiple-stdout.js', [JSON.stringify(stdout)]);66- t.is(result.stdout, foobarString);67- t.is(result.stderr, `nested ${foobarString}`);98+// eslint-disable-next-line max-params99+const testInheritStdioOutput = async (t, fdNumber, outerFdNumber, stdioOption, isSync, encoding) => {100+ const {stdio} = await execa('nested-multiple-stdio-output.js', [JSON.stringify(stdioOption), `${fdNumber}`, `${outerFdNumber}`, `${isSync}`, encoding], fullStdio);101+ t.is(stdio[fdNumber], foobarString);102+ t.is(stdio[outerFdNumber], `nested ${foobarString}`);103 };104 70-test('stdout can be ["inherit", "pipe"]', testInheritStdout, ['inherit', 'pipe']);71-test('stdout can be [1, "pipe"]', testInheritStdout, [1, 'pipe']);105+test('stdout can be ["inherit", "pipe"]', testInheritStdioOutput, 1, 2, ['inherit', 'pipe'], false, 'utf8');106+test('stdout can be [1, "pipe"]', testInheritStdioOutput, 1, 2, [1, 'pipe'], false, 'utf8');107+test('stdout can be [process.stdout, "pipe"]', testInheritStdioOutput, 1, 2, ['stdout', 'pipe'], false, 'utf8');108+test('stderr can be ["inherit", "pipe"]', testInheritStdioOutput, 2, 1, ['inherit', 'pipe'], false, 'utf8');109+test('stderr can be [2, "pipe"]', testInheritStdioOutput, 2, 1, [2, 'pipe'], false, 'utf8');110+test('stderr can be [process.stderr, "pipe"]', testInheritStdioOutput, 2, 1, ['stderr', 'pipe'], false, 'utf8');111+test('stdout can be ["inherit", "pipe"], encoding "buffer"', testInheritStdioOutput, 1, 2, ['inherit', 'pipe'], false, 'buffer');112+test('stdout can be [1, "pipe"], encoding "buffer"', testInheritStdioOutput, 1, 2, [1, 'pipe'], false, 'buffer');113+test('stdout can be [process.stdout, "pipe"], encoding "buffer"', testInheritStdioOutput, 1, 2, ['stdout', 'pipe'], false, 'buffer');114+test('stderr can be ["inherit", "pipe"], encoding "buffer"', testInheritStdioOutput, 2, 1, ['inherit', 'pipe'], false, 'buffer');115+test('stderr can be [2, "pipe"], encoding "buffer"', testInheritStdioOutput, 2, 1, [2, 'pipe'], false, 'buffer');116+test('stderr can be [process.stderr, "pipe"], encoding "buffer"', testInheritStdioOutput, 2, 1, ['stderr', 'pipe'], false, 'buffer');117+test('stdout can be ["inherit", "pipe"], sync', testInheritStdioOutput, 1, 2, ['inherit', 'pipe'], true, 'utf8');118+test('stdout can be [1, "pipe"], sync', testInheritStdioOutput, 1, 2, [1, 'pipe'], true, 'utf8');119+test('stdout can be [process.stdout, "pipe"], sync', testInheritStdioOutput, 1, 2, ['stdout', 'pipe'], true, 'utf8');120+test('stderr can be ["inherit", "pipe"], sync', testInheritStdioOutput, 2, 1, ['inherit', 'pipe'], true, 'utf8');121+test('stderr can be [2, "pipe"], sync', testInheritStdioOutput, 2, 1, [2, 'pipe'], true, 'utf8');122+test('stderr can be [process.stderr, "pipe"], sync', testInheritStdioOutput, 2, 1, ['stderr', 'pipe'], true, 'utf8');123+test('stdio[*] output can be ["inherit", "pipe"], sync', testInheritStdioOutput, 3, 1, ['inherit', 'pipe'], true, 'utf8');124+test('stdio[*] output can be [3, "pipe"], sync', testInheritStdioOutput, 3, 1, [3, 'pipe'], true, 'utf8');125+test('stdout can be ["inherit", "pipe"], encoding "buffer", sync', testInheritStdioOutput, 1, 2, ['inherit', 'pipe'], true, 'buffer');126+test('stdout can be [1, "pipe"], encoding "buffer", sync', testInheritStdioOutput, 1, 2, [1, 'pipe'], true, 'buffer');127+test('stdout can be [process.stdout, "pipe"], encoding "buffer", sync', testInheritStdioOutput, 1, 2, ['stdout', 'pipe'], true, 'buffer');128+test('stderr can be ["inherit", "pipe"], encoding "buffer", sync', testInheritStdioOutput, 2, 1, ['inherit', 'pipe'], true, 'buffer');129+test('stderr can be [2, "pipe"], encoding "buffer", sync', testInheritStdioOutput, 2, 1, [2, 'pipe'], true, 'buffer');130+test('stderr can be [process.stderr, "pipe"], encoding "buffer", sync', testInheritStdioOutput, 2, 1, ['stderr', 'pipe'], true, 'buffer');131+test('stdio[*] output can be ["inherit", "pipe"], encoding "buffer", sync', testInheritStdioOutput, 3, 1, ['inherit', 'pipe'], true, 'buffer');132+test('stdio[*] output can be [3, "pipe"], encoding "buffer", sync', testInheritStdioOutput, 3, 1, [3, 'pipe'], true, 'buffer');133 73-const testInheritStderr = async (t, stderr) => {74- const result = await execa('nested-multiple-stderr.js', [JSON.stringify(stderr)]);75- t.is(result.stdout, `nested ${foobarString}`);76- t.is(result.stderr, foobarString);134+const testFd3InheritOutput = async (t, stdioOption, isSync) => {135+ const {stdio} = await execa(getFixtureName(isSync), [JSON.stringify(getStdio(3, stdioOption)), 'noop-fd.js', '3', foobarString], fullStdio);136+ t.is(stdio[3], foobarString);137 };138 79-test('stderr can be ["inherit", "pipe"]', testInheritStderr, ['inherit', 'pipe']);80-test('stderr can be [2, "pipe"]', testInheritStderr, [2, 'pipe']);139+test('stdio[*] output can use "inherit"', testFd3InheritOutput, 'inherit', false);140+test('stdio[*] output can use ["inherit"]', testFd3InheritOutput, ['inherit'], false);141+test('stdio[*] output can use "inherit", sync', testFd3InheritOutput, 'inherit', true);142+test('stdio[*] output can use ["inherit"], sync', testFd3InheritOutput, ['inherit'], true);143 82-const testInheritNoBuffer = async (t, stdioOption) => {144+const testInheritNoBuffer = async (t, stdioOption, isSync) => {145 const filePath = tempfile();84- await execa('nested.js', [JSON.stringify({stdin: stdioOption, buffer: false}), 'nested-write.js', filePath, foobarString], {input: foobarString});146+ await execa(getFixtureName(isSync), [JSON.stringify({stdin: stdioOption, buffer: false}), 'nested-write.js', filePath, foobarString], {input: foobarString});147 t.is(await readFile(filePath, 'utf8'), `${foobarString} ${foobarString}`);148 await rm(filePath);149 };150 89-test('stdin can be ["inherit", "pipe"], buffer: false', testInheritNoBuffer, ['inherit', 'pipe']);90-test('stdin can be [0, "pipe"], buffer: false', testInheritNoBuffer, [0, 'pipe']);151+test('stdin can be ["inherit", "pipe"], buffer: false', testInheritNoBuffer, ['inherit', 'pipe'], false);152+test('stdin can be [0, "pipe"], buffer: false', testInheritNoBuffer, [0, 'pipe'], false);153+test.serial('stdin can be ["inherit", "pipe"], buffer: false, sync', testInheritNoBuffer, ['inherit', 'pipe'], true);154+test.serial('stdin can be [0, "pipe"], buffer: false, sync', testInheritNoBuffer, [0, 'pipe'], true);155 156+if (isLinux) {92-const testOverflowStream = async (t, fdNumber, stdioOption) => {93- const {stdout} = await execa('nested.js', [JSON.stringify(getStdio(fdNumber, stdioOption)), 'empty.js'], fullStdio);94- t.is(stdout, '');95-};157+ const testOverflowStream = async (t, fdNumber, stdioOption, isSync) => {158+ const {stdout} = await execa(getFixtureName(isSync), [JSON.stringify(getStdio(fdNumber, stdioOption)), 'empty.js'], fullStdio);159+ t.is(stdout, '');160+ };161 97-if (platform === 'linux') {98- test('stdin can use 4+', testOverflowStream, 0, 4);99- test('stdin can use [4+]', testOverflowStream, 0, [4]);100- test('stdout can use 4+', testOverflowStream, 1, 4);101- test('stdout can use [4+]', testOverflowStream, 1, [4]);102- test('stderr can use 4+', testOverflowStream, 2, 4);103- test('stderr can use [4+]', testOverflowStream, 2, [4]);104- test('stdio[*] can use 4+', testOverflowStream, 3, 4);105- test('stdio[*] can use [4+]', testOverflowStream, 3, [4]);162+ test('stdin can use 4+', testOverflowStream, 0, 4, false);163+ test('stdin can use [4+]', testOverflowStream, 0, [4], false);164+ test('stdout can use 4+', testOverflowStream, 1, 4, false);165+ test('stdout can use [4+]', testOverflowStream, 1, [4], false);166+ test('stderr can use 4+', testOverflowStream, 2, 4, false);167+ test('stderr can use [4+]', testOverflowStream, 2, [4], false);168+ test('stdio[*] can use 4+', testOverflowStream, 3, 4, false);169+ test('stdio[*] can use [4+]', testOverflowStream, 3, [4], false);170+ test('stdin can use 4+, sync', testOverflowStream, 0, 4, true);171+ test('stdin can use [4+], sync', testOverflowStream, 0, [4], true);172+ test('stdout can use 4+, sync', testOverflowStream, 1, 4, true);173+ test('stdout can use [4+], sync', testOverflowStream, 1, [4], true);174+ test('stderr can use 4+, sync', testOverflowStream, 2, 4, true);175+ test('stderr can use [4+], sync', testOverflowStream, 2, [4], true);176+ test('stdio[*] can use 4+, sync', testOverflowStream, 3, 4, true);177+ test('stdio[*] can use [4+], sync', testOverflowStream, 3, [4], true);178 }179 108-test('stdio[*] can use "inherit"', testOverflowStream, 3, 'inherit');109-test('stdio[*] can use ["inherit"]', testOverflowStream, 3, ['inherit']);110-180 const testOverflowStreamArray = (t, fdNumber, stdioOption) => {181 t.throws(() => {182 execa('empty.js', getStdio(fdNumber, stdioOption));183 }, {message: /no such standard stream/});3 unmodified lines187 test('stdout cannot use 4+ and another value', testOverflowStreamArray, 1, [4, 'pipe']);188 test('stderr cannot use 4+ and another value', testOverflowStreamArray, 2, [4, 'pipe']);189 test('stdio[*] cannot use 4+ and another value', testOverflowStreamArray, 3, [4, 'pipe']);190 test('stdio[*] cannot use "inherit" and another value', testOverflowStreamArray, 3, ['inherit', 'pipe']);191+192+const getInvalidFdCode = () => {193+ if (isLinux) {194+ return 'EINVAL';195+ }196+197+ return isWindows ? 'EBADF' : 'ENXIO';198+};199+200+const testOverflowStreamArraySync = (t, fdNumber) => {201+ t.throws(() => {202+ execaSync('noop-fd.js', [fdNumber, foobarString], getStdio(fdNumber, [4, 'pipe']));203+ }, {code: getInvalidFdCode()});204+};205+206+test('stdout cannot use 4+ and another value, sync', testOverflowStreamArraySync, 1);207+test('stderr cannot use 4+ and another value, sync', testOverflowStreamArraySync, 2);208+test('stdio[*] cannot use 4+ and another value, sync', testOverflowStreamArraySync, 3);209+210+test('stdin can use ["inherit", "pipe"] in a TTY', async t => {211+ const stdioOption = [['inherit', 'pipe'], 'inherit', 'pipe'];212+ const {stdout} = await execa('nested-sync-tty.js', [JSON.stringify({stdio: stdioOption}), 'false', 'stdin-fd.js', '0'], {input: foobarString});213+ t.is(stdout, foobarString);214+});215+216+const testNoTtyInput = async (t, fdNumber, optionName) => {217+ const stdioOption = ['pipe', 'inherit', 'pipe'];218+ stdioOption[fdNumber] = [[''], 'inherit', 'pipe'];219+ const {message} = await t.throwsAsync(execa('nested-sync-tty.js', [JSON.stringify({stdio: stdioOption}), 'true', 'stdin-fd.js', `${fdNumber}`], fullStdio));220+ t.true(message.includes(`The \`${optionName}: 'inherit'\` option is invalid: it cannot be a TTY`));221+};222+223+test('stdin cannot use ["inherit", "pipe"] in a TTY, sync', testNoTtyInput, 0, 'stdin');224+test('stdio[*] input cannot use ["inherit", "pipe"] in a TTY, sync', testNoTtyInput, 3, 'stdio[3]');225+226+const testTtyOutput = async (t, fdNumber, isSync) => {227+ const {stdio} = await execa('nested-sync-tty.js', [JSON.stringify(getStdio(fdNumber, ['inherit', 'pipe'])), `${isSync}`, 'noop-fd.js', `${fdNumber}`, foobarString], fullStdio);228+ t.is(stdio[fdNumber], foobarString);229+};230+231+test('stdout can use ["inherit", "pipe"] in a TTY', testTtyOutput, 1, false);232+test('stderr can use ["inherit", "pipe"] in a TTY', testTtyOutput, 2, false);233+test('stdout can use ["inherit", "pipe"] in a TTY, sync', testTtyOutput, 1, true);234+test('stderr can use ["inherit", "pipe"] in a TTY, sync', testTtyOutput, 2, true);235+test('stdio[*] output can use ["inherit", "pipe"] in a TTY, sync', testTtyOutput, 3, true);modified:test/stdio/node-stream.js+19 added
195 unmodified lines196 197 test('stdin can be [Readable, "pipe"] without a file descriptor', testLazyFileReadable, 0);198 test('stdio[*] can be [Readable, "pipe"] without a file descriptor', testLazyFileReadable, 3);199 200+const testLazyFileReadableSync = (t, fdNumber) => {201+ t.throws(() => {202+ execaSync('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [noopReadable(), 'pipe']));203+ }, {message: /cannot both be an array and include a stream/});204+};205+206+test('stdin cannot be [Readable, "pipe"] without a file descriptor, sync', testLazyFileReadableSync, 0);207+test('stdio[*] cannot be [Readable, "pipe"] without a file descriptor, sync', testLazyFileReadableSync, 3);208+209 const testLazyFileWritable = async (t, fdNumber) => {210 const filePath = tempfile();211 const stream = createWriteStream(filePath);212 6 unmodified lines219 test('stdout can be [Writable, "pipe"] without a file descriptor', testLazyFileWritable, 1);220 test('stderr can be [Writable, "pipe"] without a file descriptor', testLazyFileWritable, 2);221 test('stdio[*] can be [Writable, "pipe"] without a file descriptor', testLazyFileWritable, 3);222 223+const testLazyFileWritableSync = (t, fdNumber) => {224+ t.throws(() => {225+ execaSync('noop-fd.js', [`${fdNumber}`], getStdio(fdNumber, [noopWritable(), 'pipe']));226+ }, {message: /cannot both be an array and include a stream/});227+};228+229+test('stdout cannot be [Writable, "pipe"] without a file descriptor, sync', testLazyFileWritableSync, 1);230+test('stderr cannot be [Writable, "pipe"] without a file descriptor, sync', testLazyFileWritableSync, 2);231+test('stdio[*] cannot be [Writable, "pipe"] without a file descriptor, sync', testLazyFileWritableSync, 3);232+233 test('Waits for custom streams destroy on subprocess errors', async t => {234 let waitedForDestroy = false;235 const stream = new Writable({236 destroy: callbackify(async error => {91 unmodified linesdeleted:test/stdio/sync.js-47 removed
1-import {fileURLToPath} from 'node:url';2-import process from 'node:process';3-import test from 'ava';4-import {execaSync} from '../../index.js';5-import {setFixtureDir} from '../helpers/fixtures-dir.js';6-import {getStdio} from '../helpers/stdio.js';7-import {noopReadable, noopWritable} from '../helpers/stream.js';8-9-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-14-const inputOptions = {input: ''};15-const inputFileOptions = {inputFile: fileURLToPath(import.meta.url)};16-17-// eslint-disable-next-line max-params18-const testInvalidStdioArraySync = (t, fdNumber, stdioOption, options, expectedMessage) => {19- const {message} = t.throws(() => {20- execaSync('empty.js', {...getStdio(fdNumber, stdioOption), ...options});21- });22- t.true(message.includes(expectedMessage));23-};24-25-test('Cannot use ["inherit", "pipe"] with stdin, sync', testInvalidStdioArraySync, 0, ['inherit', 'pipe'], {}, getArrayMessage('stdin: "inherit"'));26-test('Cannot use [0, "pipe"] with stdin, sync', testInvalidStdioArraySync, 0, [0, 'pipe'], {}, getArrayMessage('stdin: 0'));27-test('Cannot use [process.stdin, "pipe"] with stdin, sync', testInvalidStdioArraySync, 0, [process.stdin, 'pipe'], {}, getArrayMessage('stdin: Stream'));28-test('Cannot use [Readable, "pipe"] with stdin, sync', testInvalidStdioArraySync, 0, [noopReadable(), 'pipe'], {}, getArrayMessage('stdin: Stream'));29-test('Cannot use "inherit" + "input" with stdin, sync', testInvalidStdioArraySync, 0, 'inherit', inputOptions, getInputMessage('stdin: "inherit"', 'input'));30-test('Cannot use 0 + "input" with stdin, sync', testInvalidStdioArraySync, 0, 0, inputOptions, getInputMessage('stdin: 0', 'input'));31-test('Cannot use process.stdin + "input" with stdin, sync', testInvalidStdioArraySync, 0, process.stdin, inputOptions, getInputMessage('stdin: Stream', 'input'));32-test('Cannot use Readable + "input" with stdin, sync', testInvalidStdioArraySync, 0, noopReadable(), inputOptions, getInputMessage('stdin: Stream', 'input'));33-test('Cannot use "inherit" + "inputFile" with stdin, sync', testInvalidStdioArraySync, 0, 'inherit', inputFileOptions, getInputMessage('stdin: "inherit"', 'inputFile'));34-test('Cannot use 0 + "inputFile" with stdin, sync', testInvalidStdioArraySync, 0, 0, inputFileOptions, getInputMessage('stdin: 0', 'inputFile'));35-test('Cannot use process.stdin + "inputFile" with stdin, sync', testInvalidStdioArraySync, 0, process.stdin, inputFileOptions, getInputMessage('stdin: Stream', 'inputFile'));36-test('Cannot use Readable + "inputFile" with stdin, sync', testInvalidStdioArraySync, 0, noopReadable(), inputFileOptions, getInputMessage('stdin: Stream', 'inputFile'));37-test('Cannot use ["inherit", "pipe"] with stdout, sync', testInvalidStdioArraySync, 1, ['inherit', 'pipe'], {}, getArrayMessage('stdout: "inherit"'));38-test('Cannot use [1, "pipe"] with stdout, sync', testInvalidStdioArraySync, 1, [1, 'pipe'], {}, getArrayMessage('stdout: 1'));39-test('Cannot use [process.stdout, "pipe"] with stdout, sync', testInvalidStdioArraySync, 1, [process.stdout, 'pipe'], {}, getArrayMessage('stdout: Stream'));40-test('Cannot use [Writable, "pipe"] with stdout, sync', testInvalidStdioArraySync, 1, [noopWritable(), 'pipe'], {}, getArrayMessage('stdout: Stream'));41-test('Cannot use ["inherit", "pipe"] with stderr, sync', testInvalidStdioArraySync, 2, ['inherit', 'pipe'], {}, getArrayMessage('stderr: "inherit"'));42-test('Cannot use [2, "pipe"] with stderr, sync', testInvalidStdioArraySync, 2, [2, 'pipe'], {}, getArrayMessage('stderr: 2'));43-test('Cannot use [process.stderr, "pipe"] with stderr, sync', testInvalidStdioArraySync, 2, [process.stderr, 'pipe'], {}, getArrayMessage('stderr: Stream'));44-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'));modified:index.d.ts+42 added-32 removed
1 import {type ChildProcess} from 'node:child_process';2 import {type Readable, type Writable, type Duplex} from 'node:stream';3 4+type Not<Value extends boolean> = Value extends true ? false : true;5+6 type And<First extends boolean, Second extends boolean> = First extends true ? Second : false;7 8 type Or<First extends boolean, Second extends boolean> = First extends true ? true : Second;9 14 unmodified lines24 | Unless<IsMainFd<FdNumber>, undefined>25 | readonly [NoStreamStdioOption<FdNumber>];26 27 type BaseStdioOption<26- IsSync extends boolean = boolean,27- IsArray extends boolean = boolean,28+ IsSync extends boolean,29+ IsExtra extends boolean,30+ IsArray extends boolean,31 > =32 | 'pipe'33 | undefined31- | Unless<And<IsSync, IsArray>, 'inherit'>34+ | Unless<And<And<Not<IsSync>, IsArray>, IsExtra>, 'inherit'>35 | Unless<IsArray, 'ignore'>36 | Unless<IsSync, 'overlapped'>;37 38 // @todo Use `string`, `Uint8Array` or `unknown` for both the argument and the return type, based on whether `encoding: 'buffer'` and `objectMode: true` are used.23 unmodified lines62 objectMode?: boolean;63 };64 65 type CommonStdioOption<63- IsSync extends boolean = boolean,64- IsArray extends boolean = boolean,66+ IsSync extends boolean,67+ IsExtra extends boolean,68+ IsArray extends boolean,69 > =66- | BaseStdioOption<IsSync, IsArray>70+ | BaseStdioOption<IsSync, IsExtra, IsArray>71 | URL72 | {file: string}73 | GeneratorTransform<IsSync>74 | GeneratorTransformFull<IsSync>71- | Unless<And<IsSync, IsArray>, number>75+ | Unless<And<Not<IsSync>, IsArray>, number>76 | Unless<Or<IsSync, IsArray>, 'ipc'>73- | Unless<IsSync,74- | DuplexTransform75- | WebTransform76- | TransformStream>;77+ | Unless<IsSync, DuplexTransform | WebTransform | TransformStream>;78 79 // Synchronous iterables excluding strings, Uint8Arrays and Arrays79-type IterableObject<IsArray extends boolean = boolean> = Iterable<unknown>80+type IterableObject<IsArray extends boolean> = Iterable<unknown>81 & object82 & {readonly BYTES_PER_ELEMENT?: never}83 & AndUnless<IsArray, {readonly lastIndexOf?: never}>;84 85 type InputStdioOption<85- IsSync extends boolean = boolean,86- IsExtra extends boolean = boolean,87- IsArray extends boolean = boolean,86+ IsSync extends boolean,87+ IsExtra extends boolean,88+ IsArray extends boolean,89 > =90+ | 091 | Unless<And<IsSync, IsExtra>, Uint8Array | IterableObject<IsArray>>92 | Unless<And<IsSync, IsArray>, Readable>93 | Unless<IsSync, AsyncIterable<unknown> | ReadableStream>;94 95 type OutputStdioOption<94- IsSync extends boolean = boolean,95- IsArray extends boolean = boolean,96+ IsSync extends boolean,97+ IsArray extends boolean,98 > =99+ | 1100+ | 2101 | Unless<And<IsSync, IsArray>, Writable>102 | Unless<IsSync, WritableStream>;103 104 type StdinSingleOption<105 IsSync extends boolean = boolean,106 IsExtra extends boolean = boolean,107 IsArray extends boolean = boolean,108 > =105- | CommonStdioOption<IsSync, IsArray>109+ | CommonStdioOption<IsSync, IsExtra, IsArray>110 | InputStdioOption<IsSync, IsExtra, IsArray>;111 112 type StdinOptionCommon<113 IsSync extends boolean = boolean,6 unmodified lines120 export type StdinOptionSync = StdinOptionCommon<true, false>;121 122 type StdoutStderrSingleOption<123 IsSync extends boolean = boolean,124+ IsExtra extends boolean = boolean,125 IsArray extends boolean = boolean,126 > =122- | CommonStdioOption<IsSync, IsArray>127+ | CommonStdioOption<IsSync, IsExtra, IsArray>128 | OutputStdioOption<IsSync, IsArray>;129 125-type StdoutStderrOptionCommon<IsSync extends boolean = boolean> =126- | StdoutStderrSingleOption<IsSync, false>127- | ReadonlyArray<StdoutStderrSingleOption<IsSync, true>>;130+type StdoutStderrOptionCommon<131+ IsSync extends boolean = boolean,132+ IsExtra extends boolean = boolean,133+> =134+ | StdoutStderrSingleOption<IsSync, IsExtra, false>135+ | ReadonlyArray<StdoutStderrSingleOption<IsSync, IsExtra, true>>;136 129-export type StdoutStderrOption = StdoutStderrOptionCommon<false>;130-export type StdoutStderrOptionSync = StdoutStderrOptionCommon<true>;137+export type StdoutStderrOption = StdoutStderrOptionCommon<false, false>;138+export type StdoutStderrOptionSync = StdoutStderrOptionCommon<true, false>;139 140 type StdioExtraOptionCommon<IsSync extends boolean = boolean> =141 | StdinOptionCommon<IsSync, true>134- | StdoutStderrOptionCommon<IsSync>;142+ | StdoutStderrOptionCommon<IsSync, true>;143 144 type StdioSingleOption<145 IsSync extends boolean = boolean,146 IsExtra extends boolean = boolean,147 IsArray extends boolean = boolean,148 > =149 | StdinSingleOption<IsSync, IsExtra, IsArray>142- | StdoutStderrSingleOption<IsSync, IsArray>;150+ | StdoutStderrSingleOption<IsSync, IsExtra, IsArray>;151 152 type StdioOptionCommon<IsSync extends boolean = boolean> =153 | StdinOptionCommon<IsSync>154 | StdoutStderrOptionCommon<IsSync>;2 unmodified lines157 export type StdioOptionSync = StdioOptionCommon<true>;158 159 type StdioOptionsArray<IsSync extends boolean = boolean> = readonly [160 StdinOptionCommon<IsSync, false>,153- StdoutStderrOptionCommon<IsSync>,154- StdoutStderrOptionCommon<IsSync>,161+ StdoutStderrOptionCommon<IsSync, false>,162+ StdoutStderrOptionCommon<IsSync, false>,163 ...ReadonlyArray<StdioExtraOptionCommon<IsSync>>,164 ];165 158-type StdioOptions<IsSync extends boolean = boolean> = BaseStdioOption<IsSync> | StdioOptionsArray<IsSync>;166+type StdioOptions<IsSync extends boolean = boolean> =167+ | BaseStdioOption<IsSync, false, false>168+ | StdioOptionsArray<IsSync>;169 170 type DefaultEncodingOption = 'utf8';171 type TextEncodingOption =172 | DefaultEncodingOption671 unmodified lines844 - both `stdout` and `stderr` options are set to [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)845 846 This is an array if the `lines` option is `true`, or if either the `stdout` or `stderr` option is a transform in object mode.847 */838- all: Unless<IsSync, AllOutput<OptionsType>>;848+ all: Unless<IsSync, AllOutput<StricterOptions<OptionsType, Options>>>;849 850 /**851 Results of the other subprocesses that were piped into this subprocess. This is useful to inspect a series of subprocesses piped with each other.852 565 unmodified lines1418 Same as `execa()` but synchronous.1419 1420 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.1421 1412-Cannot use the following options: `all`, `cleanup`, `detached`, `ipc`, `serialization`, `cancelSignal` and `forceKillAfterDelay`. 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.1422+Cannot use the following options: `all`, `cleanup`, `detached`, `ipc`, `serialization`, `cancelSignal` and `forceKillAfterDelay`. Also, the `stdin`, `stdout`, `stderr` and `stdio` options cannot be [`'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.1423 1424 @param file - The program/script to execute, as a string or file URL1425 @param arguments - Arguments to pass to `file` on execution.1426 @returns A `subprocessResult` object105 unmodified lines1532 Same as `execaCommand()` but synchronous.1533 1534 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.1535 1526-Cannot use the following options: `all`, `cleanup`, `detached`, `ipc`, `serialization`, `cancelSignal` and `forceKillAfterDelay`. 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.1536+Cannot use the following options: `all`, `cleanup`, `detached`, `ipc`, `serialization`, `cancelSignal` and `forceKillAfterDelay`. Also, the `stdin`, `stdout`, `stderr` and `stdio` options cannot be [`'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.1537 1538 @param command - The program/script to execute and its arguments.1539 @returns A `subprocessResult` object1540 @throws A `subprocessResult` error128 unmodified linesmodified:index.test-d.ts+70 added-28 removed
1525 unmodified lines1526 expectNotAssignable<StdioOptionSync>('unknown');1527 expectNotAssignable<StdioOption>(['unknown']);1528 expectNotAssignable<StdioOptionSync>(['unknown']);1529 execa('unicorns', {stdin: pipeInherit});1530-expectError(execaSync('unicorns', {stdin: pipeInherit}));1530+execaSync('unicorns', {stdin: pipeInherit});1531 execa('unicorns', {stdout: pipeInherit});1532-expectError(execaSync('unicorns', {stdout: pipeInherit}));1532+execaSync('unicorns', {stdout: pipeInherit});1533 execa('unicorns', {stderr: pipeInherit});1534-expectError(execaSync('unicorns', {stderr: pipeInherit}));1535-execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', pipeInherit]});1536-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', pipeInherit]}));1534+execaSync('unicorns', {stderr: pipeInherit});1535+expectError(execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', pipeInherit]}));1536+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', pipeInherit]});1537 expectAssignable<StdinOption>(pipeInherit);1538-expectNotAssignable<StdinOptionSync>(pipeInherit);1538+expectAssignable<StdinOptionSync>(pipeInherit);1539 expectAssignable<StdoutStderrOption>(pipeInherit);1540-expectNotAssignable<StdoutStderrOptionSync>(pipeInherit);1540+expectAssignable<StdoutStderrOptionSync>(pipeInherit);1541 expectAssignable<StdioOption>(pipeInherit);1542-expectNotAssignable<StdioOptionSync>(pipeInherit);1542+expectAssignable<StdioOptionSync>(pipeInherit);1543 execa('unicorns', {stdin: pipeUndefined});1544 execaSync('unicorns', {stdin: pipeUndefined});1545 execa('unicorns', {stdout: pipeUndefined});1546 execaSync('unicorns', {stdout: pipeUndefined});99 unmodified lines1646 expectNotAssignable<StdioOptionSync>([null]);1647 execa('unicorns', {stdin: 'inherit'});1648 execaSync('unicorns', {stdin: 'inherit'});1649 execa('unicorns', {stdin: ['inherit']});1650-expectError(execaSync('unicorns', {stdin: ['inherit']}));1650+execaSync('unicorns', {stdin: ['inherit']});1651 execa('unicorns', {stdout: 'inherit'});1652 execaSync('unicorns', {stdout: 'inherit'});1653 execa('unicorns', {stdout: ['inherit']});1654-expectError(execaSync('unicorns', {stdout: ['inherit']}));1654+execaSync('unicorns', {stdout: ['inherit']});1655 execa('unicorns', {stderr: 'inherit'});1656 execaSync('unicorns', {stderr: 'inherit'});1657 execa('unicorns', {stderr: ['inherit']});1658-expectError(execaSync('unicorns', {stderr: ['inherit']}));1658+execaSync('unicorns', {stderr: ['inherit']});1659 execa('unicorns', {stdio: 'inherit'});1660 execaSync('unicorns', {stdio: 'inherit'});1661 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'inherit']});1662 execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'inherit']});1663-execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['inherit']]});1664-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['inherit']]}));1663+expectError(execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['inherit']]}));1664+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['inherit']]});1665 expectAssignable<StdinOption>('inherit');1666 expectAssignable<StdinOptionSync>('inherit');1667 expectAssignable<StdinOption>(['inherit']);1668-expectNotAssignable<StdinOptionSync>(['inherit']);1668+expectAssignable<StdinOptionSync>(['inherit']);1669 expectAssignable<StdoutStderrOption>('inherit');1670 expectAssignable<StdoutStderrOptionSync>('inherit');1671 expectAssignable<StdoutStderrOption>(['inherit']);1672-expectNotAssignable<StdoutStderrOptionSync>(['inherit']);1672+expectAssignable<StdoutStderrOptionSync>(['inherit']);1673 expectAssignable<StdioOption>('inherit');1674 expectAssignable<StdioOptionSync>('inherit');1675-expectNotAssignable<StdioOption>(['inherit']);1676-expectNotAssignable<StdioOptionSync>(['inherit']);1675+expectAssignable<StdioOption>(['inherit']);1676+expectAssignable<StdioOptionSync>(['inherit']);1677 execa('unicorns', {stdin: 'ignore'});1678 execaSync('unicorns', {stdin: 'ignore'});1679 expectError(execa('unicorns', {stdin: ['ignore']}));1680 expectError(execaSync('unicorns', {stdin: ['ignore']}));85 unmodified lines1766 expectNotAssignable<StdioOptionSync>(['ipc']);1767 execa('unicorns', {stdin: 0});1768 execaSync('unicorns', {stdin: 0});1769 execa('unicorns', {stdin: [0]});1770-expectError(execaSync('unicorns', {stdin: [0]}));1770+execaSync('unicorns', {stdin: [0]});1771+expectError(execa('unicorns', {stdin: [1]}));1772+expectError(execa('unicorns', {stdin: [2]}));1773+execa('unicorns', {stdin: 3});1774+execaSync('unicorns', {stdin: 3});1775+expectError(execa('unicorns', {stdin: [3]}));1776+execaSync('unicorns', {stdin: [3]});1777+expectError(execa('unicorns', {stdout: [0]}));1778 execa('unicorns', {stdout: 1});1779 execaSync('unicorns', {stdout: 1});1780 execa('unicorns', {stdout: [1]});1774-expectError(execaSync('unicorns', {stdout: [1]}));1775-execa('unicorns', {stderr: 2});1781+execaSync('unicorns', {stdout: [1]});1782+execa('unicorns', {stdout: 2});1783+execaSync('unicorns', {stdout: 2});1784+execa('unicorns', {stdout: [2]});1785+execaSync('unicorns', {stdout: [2]});1786+execa('unicorns', {stdout: 3});1787+execaSync('unicorns', {stdout: 3});1788+expectError(execa('unicorns', {stdout: [3]}));1789+execaSync('unicorns', {stdout: [3]});1790+expectError(execa('unicorns', {stderr: [0]}));1791+execa('unicorns', {stderr: 1});1792+execaSync('unicorns', {stderr: 1});1793+execa('unicorns', {stderr: [1]});1794+execaSync('unicorns', {stderr: [1]});1795+execa('unicorns', {stderr: 1});1796 execaSync('unicorns', {stderr: 2});1797 execa('unicorns', {stderr: [2]});1798+execaSync('unicorns', {stderr: [2]});1799+execa('unicorns', {stderr: 3});1800+execaSync('unicorns', {stderr: 3});1801+expectError(execa('unicorns', {stderr: [3]}));1802+execaSync('unicorns', {stderr: [3]});1803+expectError(execa('unicorns', {stdio: 0}));1778-expectError(execaSync('unicorns', {stderr: [2]}));1804+expectError(execaSync('unicorns', {stdio: 0}));1805+expectError(execa('unicorns', {stdio: 1}));1806+expectError(execaSync('unicorns', {stdio: 1}));1807 expectError(execa('unicorns', {stdio: 2}));1808 expectError(execaSync('unicorns', {stdio: 2}));1809+expectError(execa('unicorns', {stdio: 3}));1810+expectError(execaSync('unicorns', {stdio: 3}));1811+execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 0]});1812+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 0]});1813+execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [0]]});1814+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [0]]});1815+execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 1]});1816+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 1]});1817+execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [1]]});1818+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [1]]});1819+execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 2]});1820+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 2]});1821+execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [2]]});1822+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [2]]});1823 execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 3]});1824 execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 3]});1783-execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [3]]});1784-expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [3]]}));1825+expectError(execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [3]]}));1826+execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [3]]});1827 expectAssignable<StdinOption>(0);1828 expectAssignable<StdinOptionSync>(0);1829 expectAssignable<StdinOption>([0]);1788-expectNotAssignable<StdinOptionSync>([0]);1830+expectAssignable<StdinOptionSync>([0]);1831 expectAssignable<StdoutStderrOption>(1);1832 expectAssignable<StdoutStderrOptionSync>(1);1833 expectAssignable<StdoutStderrOption>([1]);1792-expectNotAssignable<StdoutStderrOptionSync>([1]);1834+expectAssignable<StdoutStderrOptionSync>([1]);1835 expectAssignable<StdoutStderrOption>(2);1836 expectAssignable<StdoutStderrOptionSync>(2);1837 expectAssignable<StdoutStderrOption>([2]);1796-expectNotAssignable<StdoutStderrOptionSync>([2]);1838+expectAssignable<StdoutStderrOptionSync>([2]);1839 expectAssignable<StdioOption>(3);1840 expectAssignable<StdioOptionSync>(3);1799-expectAssignable<StdioOption>([3]);1800-expectNotAssignable<StdioOptionSync>([3]);1841+expectNotAssignable<StdioOption>([3]);1842+expectAssignable<StdioOptionSync>([3]);1843 execa('unicorns', {stdin: process.stdin});1844 execaSync('unicorns', {stdin: process.stdin});1845 execa('unicorns', {stdin: [process.stdin]});1846 expectError(execaSync('unicorns', {stdin: [process.stdin]}));1920 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), [`detached`](#detached), [`ipc`](#ipc), [`serialization`](#serialization), [`cancelSignal`](#cancelsignal) and [`forceKillAfterDelay`](#forcekillafterdelay). 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.322+Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`detached`](#detached), [`ipc`](#ipc), [`serialization`](#serialization), [`cancelSignal`](#cancelsignal) and [`forceKillAfterDelay`](#forcekillafterdelay). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1) and [`stdio`](#stdio-1) cannot be [`'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