Skip to content
Myr

Allow piping process to any file descriptor (#903)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by GitHub · parent 588bf16 · Browse files · 20 files+441 added−213 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

20 files+441 added−213 removed

  • tests:+302 added−133 removed
  • other:+139 added−80 removed

20 files+441 added−213 removed

modified:lib/pipe/setup.js+2 added-2 removed
modified:lib/pipe/validate.js+76 added-48 removed
2 unmodified lines
3import {normalizeArguments} from '../arguments/options.js';4import {STANDARD_STREAMS_ALIASES} from '../utils.js';5import {getStartTime} from '../return/duration.js';67export const normalizePipeArguments = ({source, sourcePromise, stdioStreamsGroups, destinationOptions}, ...args) => {7export const normalizePipeArguments = ({source, sourcePromise, boundOptions}, ...args) => {8 const startTime = getStartTime();9 const sourceOptions = SUBPROCESS_OPTIONS.get(source);9 const {10 destination,11 destinationStream,12 destinationError,14 pipeOptions: {from, unpipeSignal} = {},15 } = getDestinationStream(destinationOptions, ...args);16 const {sourceStream, sourceError} = getSourceStream(source, stdioStreamsGroups, from, sourceOptions);13 from,14 unpipeSignal,15 } = getDestinationStream(boundOptions, args);16 const {sourceStream, sourceError} = getSourceStream(source, from);17 const {options: sourceOptions, stdioStreamsGroups} = SUBPROCESS_OPTIONS.get(source);18 return {19 sourcePromise,20 sourceStream,21 sourceOptions,
6 unmodified lines
28 startTime,29 };30};3131const getDestinationStream = (destinationOptions, ...args) => {32const getDestinationStream = (boundOptions, args) => {33 try {33 const {destination, pipeOptions} = getDestination(destinationOptions, ...args);34 const destinationStream = destination.stdin;35 if (destinationStream === null) {36 throw new TypeError('The destination subprocess\'s stdin must be available. Please set its "stdin" option to "pipe".');37 }3839 return {destination, destinationStream, pipeOptions};34 const {35 destination,36 pipeOptions: {from, to, unpipeSignal} = {},37 } = getDestination(boundOptions, ...args);38 const destinationStream = getWritable(destination, to);39 return {destination, destinationStream, from, unpipeSignal};40 } catch (error) {41 return {destinationError: error};42 }43};4445const getDestination = (destinationOptions, firstArgument, ...args) => {45const getDestination = (boundOptions, firstArgument, ...args) => {46 if (Array.isArray(firstArgument)) {47 const destination = create$({...destinationOptions, ...PIPED_SUBPROCESS_OPTIONS})(firstArgument, ...args);48 return {destination, pipeOptions: destinationOptions};47 const destination = create$({...boundOptions, ...PIPED_SUBPROCESS_OPTIONS})(firstArgument, ...args);48 return {destination, pipeOptions: boundOptions};49 }5051 if (typeof firstArgument === 'string' || firstArgument instanceof URL) {52 if (Object.keys(destinationOptions).length > 0) {53 throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)(execa("file", ...)).');52 if (Object.keys(boundOptions).length > 0) {53 throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');54 }5556 const [rawFile, rawArgs, rawOptions] = normalizeArguments(firstArgument, ...args);57 const destination = execa(rawFile, rawArgs, {...rawOptions, ...PIPED_SUBPROCESS_OPTIONS});58 return {destination, pipeOptions: rawOptions};59 }6061 if (SUBPROCESS_OPTIONS.has(firstArgument)) {62 if (Object.keys(destinationOptions).length > 0) {62 if (Object.keys(boundOptions).length > 0) {63 throw new TypeError('Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).');64 }6566 return {destination: firstArgument, pipeOptions: args[0]};
5 unmodified lines
72const PIPED_SUBPROCESS_OPTIONS = {stdin: 'pipe', piped: true};7374export const SUBPROCESS_OPTIONS = new WeakMap();7576const getSourceStream = (source, stdioStreamsGroups, from, sourceOptions) => {77 try {78 const fdNumber = getFdNumber(stdioStreamsGroups, from);79 const sourceStream = fdNumber === 'all' ? source.all : source.stdio[fdNumber];76const getWritable = (destination, to = 'stdin') => {77 const isWritable = true;78 const {options, stdioStreamsGroups} = SUBPROCESS_OPTIONS.get(destination);79 const fdNumber = getFdNumber(stdioStreamsGroups, to, isWritable);80 const destinationStream = destination.stdio[fdNumber];8181 if (sourceStream === null || sourceStream === undefined) {82 throw new TypeError(getInvalidStdioOptionMessage(fdNumber, from, sourceOptions));83 }82 if (destinationStream === null) {83 throw new TypeError(getInvalidStdioOptionMessage(fdNumber, to, options, isWritable));84 }8586 return destinationStream;87};8889const getSourceStream = (source, from) => {90 try {91 const sourceStream = getReadable(source, from);92 return {sourceStream};93 } catch (error) {94 return {sourceError: error};95 }96};9791const getFdNumber = (stdioStreamsGroups, from = 'stdout') => {92 const fdNumber = STANDARD_STREAMS_ALIASES.includes(from)93 ? STANDARD_STREAMS_ALIASES.indexOf(from)94 : from;98const getReadable = (source, from = 'stdout') => {99 const isWritable = false;100 const {options, stdioStreamsGroups} = SUBPROCESS_OPTIONS.get(source);101 const fdNumber = getFdNumber(stdioStreamsGroups, from, isWritable);102 const sourceStream = fdNumber === 'all' ? source.all : source.stdio[fdNumber];103104 if (sourceStream === null || sourceStream === undefined) {105 throw new TypeError(getInvalidStdioOptionMessage(fdNumber, from, options, isWritable));106 }107108 return sourceStream;109};110111const getFdNumber = (stdioStreamsGroups, fdName, isWritable) => {112 const fdNumber = STANDARD_STREAMS_ALIASES.includes(fdName)113 ? STANDARD_STREAMS_ALIASES.indexOf(fdName)114 : fdName;115116 if (fdNumber === 'all') {117 return fdNumber;118 }119100 if (fdNumber === 0) {101 throw new TypeError('The "from" option must not be "stdin".');102 }103120 if (!Number.isInteger(fdNumber) || fdNumber < 0) {121 const {validOptions, defaultValue} = isWritable122 ? {validOptions: '"stdin"', defaultValue: 'stdin'}123 : {validOptions: '"stdout", "stderr", "all"', defaultValue: 'stdout'};105 throw new TypeError(`The "from" option must not be "${fdNumber}".106It must be "stdout", "stderr", "all" or a file descriptor integer.107It is optional and defaults to "stdout".`);124 throw new TypeError(`"${getOptionName(isWritable)}" must not be "${fdNumber}".125It must be ${validOptions} or a file descriptor integer.126It is optional and defaults to "${defaultValue}".`);127 }128129 const stdioStreams = stdioStreamsGroups[fdNumber];130 if (stdioStreams === undefined) {112 throw new TypeError(`The "from" option must not be ${fdNumber}. That file descriptor does not exist.131 throw new TypeError(`"${getOptionName(isWritable)}" must not be ${fdNumber}. That file descriptor does not exist.132Please set the "stdio" option to ensure that file descriptor exists.`);133 }134116 if (stdioStreams[0].direction === 'input') {117 throw new TypeError(`The "from" option must not be ${fdNumber}. It must be a readable stream, not writable.`);135 if (stdioStreams[0].direction === 'input' && !isWritable) {136 throw new TypeError(`"${getOptionName(isWritable)}" must not be ${fdNumber}. It must be a readable stream, not writable.`);137 }138139 if (stdioStreams[0].direction !== 'input' && isWritable) {140 throw new TypeError(`"${getOptionName(isWritable)}" must not be ${fdNumber}. It must be a writable stream, not readable.`);141 }142143 return fdNumber;144};145123const getInvalidStdioOptionMessage = (fdNumber, from, sourceOptions) => {124 if (fdNumber === 'all' && !sourceOptions.all) {125 return 'The "all" option must be true to use `subprocess.pipe(destinationSubprocess, {from: "all"})`.';146const getInvalidStdioOptionMessage = (fdNumber, fdName, options, isWritable) => {147 if (fdNumber === 'all' && !options.all) {148 return 'The "all" option must be true to use "from: \'all\'".';149 }150128 const {optionName, optionValue} = getInvalidStdioOption(fdNumber, sourceOptions);129 const pipeOptions = from === undefined ? '' : `, {from: ${serializeOptionValue(from)}}`;130 return `The \`${optionName}: ${serializeOptionValue(optionValue)}\` option is incompatible with using \`subprocess.pipe(destinationSubprocess${pipeOptions})\`.151 const {optionName, optionValue} = getInvalidStdioOption(fdNumber, options);152 return `The "${optionName}: ${serializeOptionValue(optionValue)}" option is incompatible with using "${getOptionName(isWritable)}: ${serializeOptionValue(fdName)}".153Please set this option with "pipe" instead.`;154};155134const getInvalidStdioOption = (fdNumber, {stdout, stderr, stdio}) => {156const getInvalidStdioOption = (fdNumber, {stdin, stdout, stderr, stdio}) => {157 const usedDescriptor = fdNumber === 'all' ? 1 : fdNumber;158159 if (usedDescriptor === 0 && stdin !== undefined) {160 return {optionName: 'stdin', optionValue: stdin};161 }162163 if (usedDescriptor === 1 && stdout !== undefined) {164 return {optionName: 'stdout', optionValue: stdout};165 }166
5 unmodified lines
172};173174const serializeOptionValue = optionValue => {175 if (typeof optionValue === 'string') {150 return `"${optionValue}"`;176 return `'${optionValue}'`;177 }178179 return typeof optionValue === 'number' ? `${optionValue}` : 'Stream';180};181182const getOptionName = isWritable => isWritable ? 'to' : 'from';
modified:lib/stream/resolve.js+1 added-1 removed
modified:lib/stream/wait.js+5 added-5 removed
56 unmodified lines
57// We ignore EPIPEs on writable streams and aborts on readable streams since those can happen normally.58// When one stream errors, the error is propagated to the other streams on the same file descriptor.59// Those other streams might have a different direction due to the above.60// When this happens, the direction of both the initial stream and the others should then be taken into account.61// Therefore, we keep track of which file descriptor is currently propagating stream errors.61// Therefore, we keep track of whether a stream error is currently propagating.62export const handleStreamError = (error, fdNumber, streamInfo, isSameDirection) => {63 if (!shouldIgnoreStreamError(error, fdNumber, streamInfo, isSameDirection)) {64 throw error;65 }66};6768const shouldIgnoreStreamError = (error, fdNumber, {stdioStreamsGroups, propagating}, isSameDirection = true) => {69 if (propagating.has(fdNumber)) {68const shouldIgnoreStreamError = (error, fdNumber, streamInfo, isSameDirection = true) => {69 if (streamInfo.propagating) {70 return isStreamEpipe(error) || isStreamAbort(error);71 }7273 propagating.add(fdNumber);74 return isInputFileDescriptor(fdNumber, stdioStreamsGroups) === isSameDirection73 streamInfo.propagating = true;74 return isInputFileDescriptor(fdNumber, streamInfo.stdioStreamsGroups) === isSameDirection75 ? isStreamEpipe(error)76 : isStreamAbort(error);77};78
21 unmodified lines
modified:lib/async.js+2 added-2 removed
15 unmodified lines
1617export const execa = (rawFile, rawArgs, rawOptions) => {18 const {file, args, command, escapedCommand, startTime, verboseInfo, options, stdioStreamsGroups, stdioState} = handleAsyncArguments(rawFile, rawArgs, rawOptions);19 const {subprocess, promise} = spawnSubprocessAsync({file, args, options, startTime, verboseInfo, command, escapedCommand, stdioStreamsGroups, stdioState});20 subprocess.pipe = pipeToSubprocess.bind(undefined, {source: subprocess, sourcePromise: promise, stdioStreamsGroups, destinationOptions: {}});20 subprocess.pipe = pipeToSubprocess.bind(undefined, {source: subprocess, sourcePromise: promise, boundOptions: {}});21 mergePromise(subprocess, promise);22 SUBPROCESS_OPTIONS.set(subprocess, options);22 SUBPROCESS_OPTIONS.set(subprocess, {options, stdioStreamsGroups});23 return subprocess;24};2526const handleAsyncArguments = (rawFile, rawArgs, rawOptions) => {
77 unmodified lines
modified:test/exit/kill.js+1 added-1 removed
177 unmodified lines
178test('Cannot call .kill(null)', testInvalidKillArgument, null);179test('Cannot call .kill(0n)', testInvalidKillArgument, 0n);180test('Cannot call .kill(true)', testInvalidKillArgument, true);181test('Cannot call .kill(errorObject)', testInvalidKillArgument, {name: '', message: '', stack: ''});182test('Cannot call .kill([error])', testInvalidKillArgument, [new Error('test')]);182test('Cannot call .kill(errorArray)', testInvalidKillArgument, [new Error('test')]);183test('Cannot call .kill(undefined, true)', testInvalidKillArgument, undefined, true);184test('Cannot call .kill("SIGTERM", true)', testInvalidKillArgument, 'SIGTERM', true);185test('Cannot call .kill(true, error)', testInvalidKillArgument, true, new Error('test'));186
120 unmodified lines
modified:test/fixtures/noop-stdin-fd.js+3 added-5 removed
added:test/fixtures/stdin-fd-both.js+8 added
modified:test/helpers/stdio.js+2 added
1import process from 'node:process';2import {noopReadable} from './stream.js';34export const identity = value => value;56export const getStdio = (fdNumberOrName, stdioOption, length = 3) => {
6 unmodified lines
13 return {stdio};14};1516export const fullStdio = getStdio(3, 'pipe');17export const fullReadableStdio = () => getStdio(3, ['pipe', noopReadable()]);1819export const STANDARD_STREAMS = [process.stdin, process.stdout, process.stderr];2021export const prematureClose = {code: 'ERR_STREAM_PREMATURE_CLOSE'};
modified:test/helpers/stream.js+3 added-1 removed
1import {Readable, Writable, PassThrough} from 'node:stream';1import {Readable, Writable, PassThrough, getDefaultHighWaterMark} from 'node:stream';2import {foobarString} from './input.js';34export const noopReadable = () => new Readable({read() {}});5export const noopWritable = () => new Writable({write() {}});6export const noopDuplex = () => new PassThrough().resume();7export const simpleReadable = () => Readable.from([foobarString]);89export const defaultHighWaterMark = getDefaultHighWaterMark(false);
modified:test/pipe/setup.js+20 added-15 removed
1import test from 'ava';2import {execa} from '../../index.js';3import {setFixtureDir} from '../helpers/fixtures-dir.js';4import {fullStdio} from '../helpers/stdio.js';4import {fullStdio, fullReadableStdio} from '../helpers/stdio.js';5import {foobarString} from '../helpers/input.js';67setFixtureDir();88const pipeToSubprocess = async (t, fdNumber, from, options) => {9 const {stdout} = await execa('noop-fd.js', [`${fdNumber}`, 'test'], options)10 .pipe(execa('stdin.js'), {from});11 t.is(stdout, 'test');9// eslint-disable-next-line max-params10const pipeToSubprocess = async (t, readableFdNumber, writableFdNumber, from, to, readableOptions = {}, writableOptions = {}) => {11 const {stdout} = await execa('noop-fd.js', [`${readableFdNumber}`, foobarString], readableOptions)12 .pipe(execa('stdin-fd.js', [`${writableFdNumber}`], writableOptions), {from, to});13 t.is(stdout, foobarString);14};1514test('pipe(...) can pipe', pipeToSubprocess, 1, undefined, {});15test('pipe(..., {from: "stdout"}) can pipe', pipeToSubprocess, 1, 'stdout', {});16test('pipe(..., {from: 1}) can pipe', pipeToSubprocess, 1, 1, {});17test('pipe(..., {from: "stderr"}) stderr can pipe', pipeToSubprocess, 2, 'stderr', {});18test('pipe(..., {from: 2}) can pipe', pipeToSubprocess, 2, 2, {});19test('pipe(..., {from: 3}) can pipe', pipeToSubprocess, 3, 3, fullStdio);20test('pipe(..., {from: "all"}) can pipe stdout', pipeToSubprocess, 1, 'all', {all: true});21test('pipe(..., {from: "all"}) can pipe stderr', pipeToSubprocess, 2, 'all', {all: true});22test('pipe(..., {from: "all"}) can pipe stdout even with "stderr: ignore"', pipeToSubprocess, 1, 'all', {all: true, stderr: 'ignore'});23test('pipe(..., {from: "all"}) can pipe stderr even with "stdout: ignore"', pipeToSubprocess, 2, 'all', {all: true, stdout: 'ignore'});16test('pipe(...) can pipe', pipeToSubprocess, 1, 0);17test('pipe(..., {from: "stdout"}) can pipe', pipeToSubprocess, 1, 0, 'stdout');18test('pipe(..., {from: 1}) can pipe', pipeToSubprocess, 1, 0, 1);19test('pipe(..., {from: "stderr"}) can pipe stderr', pipeToSubprocess, 2, 0, 'stderr');20test('pipe(..., {from: 2}) can pipe', pipeToSubprocess, 2, 0, 2);21test('pipe(..., {from: 3}) can pipe', pipeToSubprocess, 3, 0, 3, undefined, fullStdio);22test('pipe(..., {from: "all"}) can pipe stdout', pipeToSubprocess, 1, 0, 'all', undefined, {all: true});23test('pipe(..., {from: "all"}) can pipe stderr', pipeToSubprocess, 2, 0, 'all', undefined, {all: true});24test('pipe(..., {from: "all"}) can pipe stdout even with "stderr: ignore"', pipeToSubprocess, 1, 0, 'all', undefined, {all: true, stderr: 'ignore'});25test('pipe(..., {from: "all"}) can pipe stderr even with "stdout: ignore"', pipeToSubprocess, 2, 0, 'all', undefined, {all: true, stdout: 'ignore'});26test('pipe(..., {to: "stdin"}) can pipe', pipeToSubprocess, 1, 0, undefined, 'stdin');27test('pipe(..., {to: 0}) can pipe', pipeToSubprocess, 1, 0, undefined, 0);28test('pipe(..., {to: 3}) can pipe', pipeToSubprocess, 1, 3, undefined, 3, {}, fullReadableStdio());
modified:test/pipe/streaming.js+13 added
3 unmodified lines
4import {execa} from '../../index.js';5import {setFixtureDir} from '../helpers/fixtures-dir.js';6import {foobarString} from '../helpers/input.js';7import {assertMaxListeners} from '../helpers/listeners.js';8import {fullReadableStdio} from '../helpers/stdio.js';910setFixtureDir();1112test('Can pipe two sources to same destination', async t => {
74 unmodified lines
87 t.is(await pipePromise, await destination);88 t.is(await secondPipePromise, await destination);89});9091test('Can pipe same source to two streams from same subprocess', async t => {92 const source = execa('noop-fd.js', ['1', foobarString]);93 const destination = execa('stdin-fd-both.js', ['3'], fullReadableStdio());94 const pipePromise = source.pipe(destination);95 const secondPipePromise = source.pipe(destination, {to: 3});9697 t.like(await source, {stdout: foobarString});98 t.like(await destination, {stdout: `${foobarString}${foobarString}`});99 t.is(await pipePromise, await destination);100 t.is(await secondPipePromise, await destination);101});102103test('Can pipe a new source to same destination after some source has already written', async t => {104 const passThroughStream = new PassThrough();105 const source = execa('stdin.js', {stdin: ['pipe', passThroughStream]});106 const destination = execa('stdin.js');
335 unmodified lines
modified:test/pipe/template.js+1 added-1 removed
227 unmodified lines
228229test('execa.pipe(subprocess) does not force "stdin: pipe"', async t => {230 await t.throwsAsync(231 execa('noop.js', [foobarString]).pipe(execa('stdin.js', {stdin: 'ignore'})),232 {message: /stdin must be available/},232 {message: /"stdin: 'ignore'" option is incompatible/},233 );234});235236test('$.pipe(options)(subprocess) fails', async t => {
36 unmodified lines
modified:test/pipe/validate.js+241 added-103 removed
3 unmodified lines
4import test from 'ava';5import {execa} from '../../index.js';6import {setFixtureDir} from '../helpers/fixtures-dir.js';7import {foobarString} from '../helpers/input.js';8import {fullStdio, getStdio} from '../helpers/stdio.js';9import {getEarlyErrorSubprocess} from '../helpers/early-error.js';1011setFixtureDir();12
23 unmodified lines
3637 t.true(error.originalMessage.includes(message));38};3939test('Must set "all" option to "true" to use pipe(..., {from: "all"})', async t => {40 await assertPipeError(41 t,42 execa('empty.js')43 .pipe(execa('empty.js'), {from: 'all'}),44 '"all" option must be true',45 );46});40const getMessage = message => Array.isArray(message)41 ? `"${message[0]}: ${message[1]}" option is incompatible`42 : message;4348const invalidDestination = async (t, getDestination) => {49 await assertPipeError(50 t,51 execa('empty.js')52 .pipe(getDestination()),53 'an Execa subprocess',54 );44const testPipeError = async (t, {45 message,46 sourceOptions = {},47 destinationOptions = {},48 getSource = () => execa('empty.js', sourceOptions),49 getDestination = () => execa('empty.js', destinationOptions),50 isScript = false,51 from,52 to,53}) => {54 const source = getSource();55 const pipePromise = isScript ? source.pipe({from, to})`empty.js` : source.pipe(getDestination(), {from, to});56 await assertPipeError(t, pipePromise, getMessage(message));57};5857test('pipe() cannot pipe to non-subprocesses', invalidDestination, () => new PassThrough());58test('pipe() cannot pipe to non-Execa subprocesses', invalidDestination, () => spawn('node', ['--version']));5960test('pipe() "from" option cannot be "stdin"', async t => {61 await assertPipeError(62 t,63 execa('empty.js')64 .pipe(execa('empty.js'), {from: 'stdin'}),65 'not be "stdin"',66 );59test('Must set "all" option to "true" to use .pipe("all")', testPipeError, {60 from: 'all',61 message: '"all" option must be true',62});6869test('$.pipe() "from" option cannot be "stdin"', async t => {70 await assertPipeError(71 t,72 execa('empty.js')73 .pipe({from: 'stdin'})`empty.js`,74 'not be "stdin"',75 );63test('.pipe() cannot pipe to non-subprocesses', testPipeError, {64 getDestination: () => new PassThrough(),65 message: 'an Execa subprocess',66});7778const invalidFromOption = async (t, from) => {79 await assertPipeError(80 t,81 execa('empty.js')82 .pipe(execa('empty.js'), {from}),83 '"from" option must not be',84 );85};8687test('pipe() "from" option cannot be any string', invalidFromOption, 'other');88test('pipe() "from" option cannot be a float', invalidFromOption, 1.5);89test('pipe() "from" option cannot be a negative number', invalidFromOption, -1);9091test('pipe() "from" option cannot be a non-existing file descriptor', async t => {92 await assertPipeError(93 t,94 execa('empty.js')95 .pipe(execa('empty.js'), {from: 3}),96 'file descriptor does not exist',97 );67test('.pipe() cannot pipe to non-Execa subprocesses', testPipeError, {68 getDestination: () => spawn('node', ['--version']),69 message: 'an Execa subprocess',70});99100test('pipe() "from" option cannot be an input file descriptor', async t => {101 await assertPipeError(102 t,103 execa('stdin-fd.js', ['3'], {stdio: ['pipe', 'pipe', 'pipe', new Uint8Array()]})104 .pipe(execa('empty.js'), {from: 3}),105 'must be a readable stream',106 );71test('.pipe() "from" option cannot be "stdin"', testPipeError, {72 from: 'stdin',73 message: '"from" must not be',74});108109test('Must set destination "stdin" option to "pipe" to use pipe()', async t => {110 await assertPipeError(111 t,112 execa('empty.js')113 .pipe(execa('stdin.js', {stdin: 'ignore'})),114 'stdin must be available',115 );75test('$.pipe() "from" option cannot be "stdin"', testPipeError, {76 from: 'stdin',77 isScript: true,78 message: '"from" must not be',79});80test('.pipe() "to" option cannot be "stdout"', testPipeError, {81 to: 'stdout',82 message: '"to" must not be',83});84test('$.pipe() "to" option cannot be "stdout"', testPipeError, {85 to: 'stdout',86 isScript: true,87 message: '"to" must not be',88});89test('.pipe() "from" option cannot be any string', testPipeError, {90 from: 'other',91 message: 'must be "stdout", "stderr", "all"',92});93test('.pipe() "to" option cannot be any string', testPipeError, {94 to: 'other',95 message: 'must be "stdin"',96});97test('.pipe() "from" option cannot be a float', testPipeError, {98 from: 1.5,99 message: 'must be "stdout", "stderr", "all"',100});101test('.pipe() "to" option cannot be a float', testPipeError, {102 to: 1.5,103 message: 'must be "stdin"',104});105test('.pipe() "from" option cannot be a negative number', testPipeError, {106 from: -1,107 message: 'must be "stdout", "stderr", "all"',108});109test('.pipe() "to" option cannot be a negative number', testPipeError, {110 to: -1,111 message: 'must be "stdin"',112});113test('.pipe() "from" option cannot be a non-existing file descriptor', testPipeError, {114 from: 3,115 message: 'file descriptor does not exist',116});117test('.pipe() "to" option cannot be a non-existing file descriptor', testPipeError, {118 to: 3,119 message: 'file descriptor does not exist',120});121test('.pipe() "from" option cannot be an input file descriptor', testPipeError, {122 sourceOptions: getStdio(3, new Uint8Array()),123 from: 3,124 message: 'must be a readable stream',125});126test('.pipe() "to" option cannot be an output file descriptor', testPipeError, {127 destinationOptions: fullStdio,128 to: 3,129 message: 'must be a writable stream',130});131test('Cannot set "stdout" option to "ignore" to use .pipe()', testPipeError, {132 sourceOptions: {stdout: 'ignore'},133 message: ['stdout', '\'ignore\''],134});135test('Cannot set "stdin" option to "ignore" to use .pipe()', testPipeError, {136 destinationOptions: {stdin: 'ignore'},137 message: ['stdin', '\'ignore\''],138});139test('Cannot set "stdout" option to "ignore" to use .pipe(1)', testPipeError, {140 sourceOptions: {stdout: 'ignore'},141 from: 1,142 message: ['stdout', '\'ignore\''],143});144test('Cannot set "stdin" option to "ignore" to use .pipe(0)', testPipeError, {145 destinationOptions: {stdin: 'ignore'},146 message: ['stdin', '\'ignore\''],147 to: 0,148});149test('Cannot set "stdout" option to "ignore" to use .pipe("stdout")', testPipeError, {150 sourceOptions: {stdout: 'ignore'},151 from: 'stdout',152 message: ['stdout', '\'ignore\''],153});154test('Cannot set "stdin" option to "ignore" to use .pipe("stdin")', testPipeError, {155 destinationOptions: {stdin: 'ignore'},156 message: ['stdin', '\'ignore\''],157 to: 'stdin',158});159test('Cannot set "stdout" + "stderr" option to "ignore" to use .pipe()', testPipeError, {160 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},161 message: ['stdout', '\'ignore\''],162});163test('Cannot set "stdout" + "stderr" option to "ignore" to use .pipe(1)', testPipeError, {164 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},165 from: 1,166 message: ['stdout', '\'ignore\''],167});168test('Cannot set "stdout" + "stderr" option to "ignore" to use .pipe("stdout")', testPipeError, {169 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},170 from: 'stdout',171 message: ['stdout', '\'ignore\''],172});173test('Cannot set "stdio[1]" option to "ignore" to use .pipe()', testPipeError, {174 sourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},175 message: ['stdio[1]', '\'ignore\''],176});177test('Cannot set "stdio[0]" option to "ignore" to use .pipe()', testPipeError, {178 destinationOptions: {stdio: ['ignore', 'pipe', 'pipe']},179 message: ['stdio[0]', '\'ignore\''],180});181test('Cannot set "stdio[1]" option to "ignore" to use .pipe(1)', testPipeError, {182 sourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},183 from: 1,184 message: ['stdio[1]', '\'ignore\''],185});186test('Cannot set "stdio[0]" option to "ignore" to use .pipe(0)', testPipeError, {187 destinationOptions: {stdio: ['ignore', 'pipe', 'pipe']},188 message: ['stdio[0]', '\'ignore\''],189 to: 0,190});191test('Cannot set "stdio[1]" option to "ignore" to use .pipe("stdout")', testPipeError, {192 sourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},193 from: 'stdout',194 message: ['stdio[1]', '\'ignore\''],195});196test('Cannot set "stdio[0]" option to "ignore" to use .pipe("stdin")', testPipeError, {197 destinationOptions: {stdio: ['ignore', 'pipe', 'pipe']},198 message: ['stdio[0]', '\'ignore\''],199 to: 'stdin',200});201test('Cannot set "stderr" option to "ignore" to use .pipe(2)', testPipeError, {202 sourceOptions: {stderr: 'ignore'},203 from: 2,204 message: ['stderr', '\'ignore\''],205});206test('Cannot set "stderr" option to "ignore" to use .pipe("stderr")', testPipeError, {207 sourceOptions: {stderr: 'ignore'},208 from: 'stderr',209 message: ['stderr', '\'ignore\''],210});211test('Cannot set "stdout" + "stderr" option to "ignore" to use .pipe(2)', testPipeError, {212 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},213 from: 2,214 message: ['stderr', '\'ignore\''],215});216test('Cannot set "stdout" + "stderr" option to "ignore" to use .pipe("stderr")', testPipeError, {217 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},218 from: 'stderr',219 message: ['stderr', '\'ignore\''],220});221test('Cannot set "stdio[2]" option to "ignore" to use .pipe(2)', testPipeError, {222 sourceOptions: {stdio: ['pipe', 'pipe', 'ignore']},223 from: 2,224 message: ['stdio[2]', '\'ignore\''],225});226test('Cannot set "stdio[2]" option to "ignore" to use .pipe("stderr")', testPipeError, {227 sourceOptions: {stdio: ['pipe', 'pipe', 'ignore']},228 from: 'stderr',229 message: ['stdio[2]', '\'ignore\''],230});231test('Cannot set "stdio[3]" option to "ignore" to use .pipe(3)', testPipeError, {232 sourceOptions: getStdio(3, 'ignore'),233 from: 3,234 message: ['stdio[3]', '\'ignore\''],235});236test('Cannot set "stdout" + "stderr" option to "ignore" to use .pipe("all")', testPipeError, {237 sourceOptions: {stdout: 'ignore', stderr: 'ignore', all: true},238 from: 'all',239 message: ['stdout', '\'ignore\''],240});241test('Cannot set "stdio[1]" + "stdio[2]" option to "ignore" to use .pipe("all")', testPipeError, {242 sourceOptions: {stdio: ['pipe', 'ignore', 'ignore'], all: true},243 from: 'all',244 message: ['stdio[1]', '\'ignore\''],245});246test('Cannot set "stdout" option to "inherit" to use .pipe()', testPipeError, {247 sourceOptions: {stdout: 'inherit'},248 message: ['stdout', '\'inherit\''],249});250test('Cannot set "stdin" option to "inherit" to use .pipe()', testPipeError, {251 destinationOptions: {stdin: 'inherit'},252 message: ['stdin', '\'inherit\''],253});254test('Cannot set "stdout" option to "ipc" to use .pipe()', testPipeError, {255 sourceOptions: {stdout: 'ipc'},256 message: ['stdout', '\'ipc\''],257});258test('Cannot set "stdin" option to "ipc" to use .pipe()', testPipeError, {259 destinationOptions: {stdin: 'ipc'},260 message: ['stdin', '\'ipc\''],261});262test('Cannot set "stdout" option to file descriptors to use .pipe()', testPipeError, {263 sourceOptions: {stdout: 1},264 message: ['stdout', '1'],265});266test('Cannot set "stdin" option to file descriptors to use .pipe()', testPipeError, {267 destinationOptions: {stdin: 0},268 message: ['stdin', '0'],269});270test('Cannot set "stdout" option to Node.js streams to use .pipe()', testPipeError, {271 sourceOptions: {stdout: process.stdout},272 message: ['stdout', 'Stream'],273});274test('Cannot set "stdin" option to Node.js streams to use .pipe()', testPipeError, {275 destinationOptions: {stdin: process.stdin},276 message: ['stdin', 'Stream'],277});278test('Cannot set "stdio[3]" option to Node.js Writable streams to use .pipe()', testPipeError, {279 sourceOptions: getStdio(3, process.stdout),280 message: ['stdio[3]', 'Stream'],281 from: 3,282});283test('Cannot set "stdio[3]" option to Node.js Readable streams to use .pipe()', testPipeError, {284 destinationOptions: getStdio(3, process.stdin),285 message: ['stdio[3]', 'Stream'],286 to: 3,287});288118// eslint-disable-next-line max-params119const invalidSource = async (t, optionName, optionValue, from, options) => {120 await assertPipeError(121 t,122 execa('empty.js', options)123 .pipe(execa('empty.js'), {from}),124 `\`${optionName}: ${optionValue}\` option is incompatible`,125 );126};127128test('Cannot set "stdout" option to "ignore" to use pipe(...)', invalidSource, 'stdout', '"ignore"', undefined, {stdout: 'ignore'});129test('Cannot set "stdout" option to "ignore" to use pipe(..., 1)', invalidSource, 'stdout', '"ignore"', 1, {stdout: 'ignore'});130test('Cannot set "stdout" option to "ignore" to use pipe(..., "stdout")', invalidSource, 'stdout', '"ignore"', 'stdout', {stdout: 'ignore'});131test('Cannot set "stdout" + "stderr" option to "ignore" to use pipe(...)', invalidSource, 'stdout', '"ignore"', undefined, {stdout: 'ignore', stderr: 'ignore'});132test('Cannot set "stdout" + "stderr" option to "ignore" to use pipe(..., 1)', invalidSource, 'stdout', '"ignore"', 1, {stdout: 'ignore', stderr: 'ignore'});133test('Cannot set "stdout" + "stderr" option to "ignore" to use pipe(..., "stdout")', invalidSource, 'stdout', '"ignore"', 'stdout', {stdout: 'ignore', stderr: 'ignore'});134test('Cannot set "stdio[1]" option to "ignore" to use pipe(...)', invalidSource, 'stdio[1]', '"ignore"', undefined, {stdio: ['pipe', 'ignore', 'pipe']});135test('Cannot set "stdio[1]" option to "ignore" to use pipe(..., 1)', invalidSource, 'stdio[1]', '"ignore"', 1, {stdio: ['pipe', 'ignore', 'pipe']});136test('Cannot set "stdio[1]" option to "ignore" to use pipe(..., "stdout")', invalidSource, 'stdio[1]', '"ignore"', 'stdout', {stdio: ['pipe', 'ignore', 'pipe']});137test('Cannot set "stderr" option to "ignore" to use pipe(..., 2)', invalidSource, 'stderr', '"ignore"', 2, {stderr: 'ignore'});138test('Cannot set "stderr" option to "ignore" to use pipe(..., "stderr")', invalidSource, 'stderr', '"ignore"', 'stderr', {stderr: 'ignore'});139test('Cannot set "stdout" + "stderr" option to "ignore" to use pipe(..., 2)', invalidSource, 'stderr', '"ignore"', 2, {stdout: 'ignore', stderr: 'ignore'});140test('Cannot set "stdout" + "stderr" option to "ignore" to use pipe(..., "stderr")', invalidSource, 'stderr', '"ignore"', 'stderr', {stdout: 'ignore', stderr: 'ignore'});141test('Cannot set "stdio[2]" option to "ignore" to use pipe(..., 2)', invalidSource, 'stdio[2]', '"ignore"', 2, {stdio: ['pipe', 'pipe', 'ignore']});142test('Cannot set "stdio[2]" option to "ignore" to use pipe(..., "stderr")', invalidSource, 'stdio[2]', '"ignore"', 'stderr', {stdio: ['pipe', 'pipe', 'ignore']});143test('Cannot set "stdio[3]" option to "ignore" to use pipe(..., 3)', invalidSource, 'stdio[3]', '"ignore"', 3, {stdio: ['pipe', 'pipe', 'pipe', 'ignore']});144test('Cannot set "stdout" + "stderr" option to "ignore" to use pipe(..., "all")', invalidSource, 'stdout', '"ignore"', 'all', {stdout: 'ignore', stderr: 'ignore', all: true});145test('Cannot set "stdio[1]" + "stdio[2]" option to "ignore" to use pipe(..., "all")', invalidSource, 'stdio[1]', '"ignore"', 'all', {stdio: ['pipe', 'ignore', 'ignore'], all: true});146test('Cannot set "stdout" option to "inherit" to use pipe()', invalidSource, 'stdout', '"inherit"', 1, {stdout: 'inherit'});147test('Cannot set "stdout" option to "ipc" to use pipe()', invalidSource, 'stdout', '"ipc"', 1, {stdout: 'ipc'});148test('Cannot set "stdout" option to file descriptors to use pipe()', invalidSource, 'stdout', '1', 1, {stdout: 1});149test('Cannot set "stdout" option to Node.js streams to use pipe()', invalidSource, 'stdout', 'Stream', 1, {stdout: process.stdout});150289test('Destination stream is ended when first argument is invalid', async t => {290 const source = execa('empty.js', {stdout: 'ignore'});291 const destination = execa('stdin.js');292 const pipePromise = source.pipe(destination);
56 unmodified lines
modified:test/return/early-error.js+4 added-1 removed
77 unmodified lines
78test('child_process.spawn() early errors can use .pipe`` multiple times', testEarlyErrorPipe, () => $(earlyErrorOptions)`empty.js`.pipe(earlyErrorOptions)`empty.js`.pipe`empty.js`);7980const testEarlyErrorStream = async (t, getStreamProperty, all) => {81 const subprocess = getEarlyErrorSubprocess({all});82 getStreamProperty(subprocess).on('end', () => {});82 const stream = getStreamProperty(subprocess);83 stream.on('close', () => {});84 stream.read?.();85 stream.end?.();86 await t.throwsAsync(subprocess);87};8889test('child_process.spawn() early errors can use .stdin', testEarlyErrorStream, ({stdin}) => stdin, false);
4 unmodified lines
modified:test/stdio/transform.js+4 added-4 removed
1import {Buffer} from 'node:buffer';2import {once} from 'node:events';3import {setTimeout, scheduler} from 'node:timers/promises';4import {getDefaultHighWaterMark} from 'node:stream';4import test from 'ava';5import {getStreamAsArray} from 'get-stream';6import {execa} from '../../index.js';7import {foobarString} from '../helpers/input.js';
5 unmodified lines
13 outputObjectGenerator,14 convertTransformToFinal,15 noYieldGenerator,16} from '../helpers/generator.js';17import {defaultHighWaterMark} from '../helpers/stream.js';18import {setFixtureDir} from '../helpers/fixtures-dir.js';1920setFixtureDir();21
4 unmodified lines
2627test('Generators "final" can be used', testGeneratorFinal, 'noop.js');28test('Generators "final" is used even on empty streams', testGeneratorFinal, 'empty.js');2930const repeatCount = getDefaultHighWaterMark() * 3;30const repeatCount = defaultHighWaterMark * 3;3132const writerGenerator = function * () {33 for (let index = 0; index < repeatCount; index += 1) {34 yield '\n';
54 unmodified lines
8990const partsPerChunk = 4;91const chunksPerCall = 10;92const callCount = 5;93const fullString = '\n'.repeat(getDefaultHighWaterMark(false) / partsPerChunk);93const fullString = '\n'.repeat(defaultHighWaterMark / partsPerChunk);9495const yieldFullStrings = function * () {96 yield * Array.from({length: partsPerChunk * chunksPerCall}).fill(fullString);97};
8 unmodified lines
106107const testManyYields = async (t, final) => {108 const subprocess = execa('noop.js', {stdout: convertTransformToFinal(manyYieldGenerator, final), buffer: false});109 const [chunks] = await Promise.all([getStreamAsArray(subprocess.stdout), subprocess]);110 const expectedChunk = Buffer.alloc(getDefaultHighWaterMark(false) * chunksPerCall).fill('\n');110 const expectedChunk = Buffer.alloc(defaultHighWaterMark * chunksPerCall).fill('\n');111 t.deepEqual(chunks, Array.from({length: callCount}).fill(expectedChunk));112};113114test('Generator "transform" yields are sent right away', testManyYields, false);
90 unmodified lines
modified:test/stream/all.js+2 added-2 removed
1import {getDefaultHighWaterMark} from 'node:stream';1import test from 'ava';2import {execa} from '../../index.js';3import {setFixtureDir} from '../helpers/fixtures-dir.js';4import {defaultHighWaterMark} from '../helpers/stream.js';56setFixtureDir();78test.serial('result.all shows both `stdout` and `stderr` intermixed', async t => {
13 unmodified lines
2223const testAllProperties = async (t, options) => {24 const subprocess = execa('empty.js', {...options, all: true});25 t.is(subprocess.all.readableObjectMode, false);26 t.is(subprocess.all.readableHighWaterMark, getDefaultHighWaterMark(false));26 t.is(subprocess.all.readableHighWaterMark, defaultHighWaterMark);27 await subprocess;28};2930test('subprocess.all has the right objectMode and highWaterMark - stdout + stderr', testAllProperties, {});
31 unmodified lines
modified:index.d.ts+6 added-1 removed
830 unmodified lines
831 : Readable;832833type PipeOptions = {834 /**835 Which stream to pipe. A file descriptor number can also be passed.835 Which stream to pipe from the source subprocess. A file descriptor number can also be passed.836837 `"all"` pipes both `stdout` and `stderr`. This requires the `all` option to be `true`.838 */839 readonly from?: 'stdout' | 'stderr' | 'all' | number;840841 /**842 Which stream to pipe to the destination subprocess. A file descriptor number can also be passed.843 */844 readonly to?: 'stdin' | number;845846 /**847 Unpipe the subprocess when the signal aborts.848849 The `.pipe()` method will be rejected with a cancellation error.850 */
548 unmodified lines
modified:index.test-d.ts+39 added-20 removed
86 unmodified lines
87 const bufferResult = await execaBufferPromise;8889 const scriptPromise = $`unicorns`;9091 const pipeOptions = {from: 'stderr', all: true} as const;91 const pipeOptions = {from: 'stderr', to: 3, all: true} as const;9293 type BufferExecaReturnValue = typeof bufferResult;94 type EmptyExecaReturnValue = ExecaResult<{}>;95 type ShortcutExecaReturnValue = ExecaResult<typeof pipeOptions>;
23 unmodified lines
119 expectType<EmptyExecaReturnValue>(await execaPromise.pipe('pipe').pipe`stdin`);120 expectType<EmptyExecaReturnValue>(await scriptPromise.pipe('pipe').pipe`stdin`);121 expectType<ShortcutExecaReturnValue>(await execaPromise.pipe('pipe').pipe('stdin', pipeOptions));122 expectType<ShortcutExecaReturnValue>(await scriptPromise.pipe('pipe').pipe('stdin', pipeOptions));123 await execaPromise.pipe(execaPromise).pipe(execaBufferPromise, {from: 'stdout'});124 await scriptPromise.pipe(execaPromise).pipe(execaBufferPromise, {from: 'stdout'});125 await execaPromise.pipe(execaBufferPromise, {from: 'stdout'}).pipe`stdin`;126 await scriptPromise.pipe(execaBufferPromise, {from: 'stdout'}).pipe`stdin`;127 await execaPromise.pipe(execaBufferPromise, {from: 'stdout'}).pipe('stdin');128 await scriptPromise.pipe(execaBufferPromise, {from: 'stdout'}).pipe('stdin');129 await execaPromise.pipe`stdin`.pipe(execaBufferPromise, {from: 'stdout'});130 await scriptPromise.pipe`stdin`.pipe(execaBufferPromise, {from: 'stdout'});131 await execaPromise.pipe`stdin`.pipe({from: 'stdout'})`stdin`;132 await scriptPromise.pipe`stdin`.pipe({from: 'stdout'})`stdin`;133 await execaPromise.pipe`stdin`.pipe('stdin', {from: 'stdout'});134 await scriptPromise.pipe`stdin`.pipe('stdin', {from: 'stdout'});123 await execaPromise.pipe(execaPromise).pipe(execaBufferPromise, pipeOptions);124 await scriptPromise.pipe(execaPromise).pipe(execaBufferPromise, pipeOptions);125 await execaPromise.pipe(execaBufferPromise, pipeOptions).pipe`stdin`;126 await scriptPromise.pipe(execaBufferPromise, pipeOptions).pipe`stdin`;127 await execaPromise.pipe(execaBufferPromise, pipeOptions).pipe('stdin');128 await scriptPromise.pipe(execaBufferPromise, pipeOptions).pipe('stdin');129 await execaPromise.pipe`stdin`.pipe(execaBufferPromise, pipeOptions);130 await scriptPromise.pipe`stdin`.pipe(execaBufferPromise, pipeOptions);131 await execaPromise.pipe`stdin`.pipe(pipeOptions)`stdin`;132 await scriptPromise.pipe`stdin`.pipe(pipeOptions)`stdin`;133 await execaPromise.pipe`stdin`.pipe('stdin', pipeOptions);134 await scriptPromise.pipe`stdin`.pipe('stdin', pipeOptions);135 expectError(execaPromise.pipe(execaBufferPromise).stdout);136 expectError(scriptPromise.pipe(execaBufferPromise).stdout);137 expectError(execaPromise.pipe`stdin`.stdout);138 expectError(scriptPromise.pipe`stdin`.stdout);
36 unmodified lines
175 await execaPromise.pipe({from: 3})`stdin`;176 await scriptPromise.pipe({from: 3})`stdin`;177 await execaPromise.pipe('stdin', {from: 3});178 await scriptPromise.pipe('stdin', {from: 3});179 expectError(execaPromise.pipe(execaBufferPromise, {from: 'other'}));180 expectError(scriptPromise.pipe(execaBufferPromise, {from: 'other'}));181 expectError(execaPromise.pipe({from: 'other'})`stdin`);182 expectError(scriptPromise.pipe({from: 'other'})`stdin`);183 expectError(execaPromise.pipe('stdin', {from: 'other'}));184 expectError(scriptPromise.pipe('stdin', {from: 'other'}));179 expectError(execaPromise.pipe(execaBufferPromise, {from: 'stdin'}));180 expectError(scriptPromise.pipe(execaBufferPromise, {from: 'stdin'}));181 expectError(execaPromise.pipe({from: 'stdin'})`stdin`);182 expectError(scriptPromise.pipe({from: 'stdin'})`stdin`);183 expectError(execaPromise.pipe('stdin', {from: 'stdin'}));184 expectError(scriptPromise.pipe('stdin', {from: 'stdin'}));185 await execaPromise.pipe(execaBufferPromise, {to: 'stdin'});186 await scriptPromise.pipe(execaBufferPromise, {to: 'stdin'});187 await execaPromise.pipe({to: 'stdin'})`stdin`;188 await scriptPromise.pipe({to: 'stdin'})`stdin`;189 await execaPromise.pipe('stdin', {to: 'stdin'});190 await scriptPromise.pipe('stdin', {to: 'stdin'});191 await execaPromise.pipe(execaBufferPromise, {to: 3});192 await scriptPromise.pipe(execaBufferPromise, {to: 3});193 await execaPromise.pipe({to: 3})`stdin`;194 await scriptPromise.pipe({to: 3})`stdin`;195 await execaPromise.pipe('stdin', {to: 3});196 await scriptPromise.pipe('stdin', {to: 3});197 expectError(execaPromise.pipe(execaBufferPromise, {to: 'stdout'}));198 expectError(scriptPromise.pipe(execaBufferPromise, {to: 'stdout'}));199 expectError(execaPromise.pipe({to: 'stdout'})`stdin`);200 expectError(scriptPromise.pipe({to: 'stdout'})`stdin`);201 expectError(execaPromise.pipe('stdin', {to: 'stdout'}));202 expectError(scriptPromise.pipe('stdin', {to: 'stdout'}));203 await execaPromise.pipe(execaBufferPromise, {unpipeSignal: new AbortController().signal});204 await scriptPromise.pipe(execaBufferPromise, {unpipeSignal: new AbortController().signal});205 await execaPromise.pipe({unpipeSignal: new AbortController().signal})`stdin`;206 await scriptPromise.pipe({unpipeSignal: new AbortController().signal})`stdin`;
17 unmodified lines
224 await execaPromise.pipe(fileUrl);225 await execaPromise.pipe('stdin', []);226 await execaPromise.pipe('stdin', ['foo', 'bar']);227 await execaPromise.pipe('stdin', ['foo', 'bar'], {});210 await execaPromise.pipe('stdin', ['foo', 'bar'], {from: 'stderr', all: true});228 await execaPromise.pipe('stdin', ['foo', 'bar'], {from: 'stderr', to: 'stdin', all: true});229 await execaPromise.pipe('stdin', {from: 'stderr'});230 await execaPromise.pipe('stdin', {to: 'stdin'});231 await execaPromise.pipe('stdin', {all: true});232 expectError(await execaPromise.pipe(['foo', 'bar']));233 expectError(await execaPromise.pipe('stdin', 'foo'));234 expectError(await execaPromise.pipe('stdin', [false]));
1356 unmodified lines
modified:readme.md+8 added-1 removed
395 unmodified lines
396397Type: `"stdout" | "stderr" | "all" | number`\398Default: `"stdout"`399400Which stream to pipe. A file descriptor number can also be passed.400Which stream to pipe from the source subprocess. A file descriptor number can also be passed.401402`"all"` pipes both `stdout` and `stderr`. This requires the [`all` option](#all-2) to be `true`.403404##### pipeOptions.to405406Type: `"stdin" | number`\407Default: `"stdin"`408409Which stream to pipe to the destination subprocess. A file descriptor number can also be passed.410411##### pipeOptions.unpipeSignal412413Type: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)414
657 unmodified lines