Skip to content
Myr

Line-wise standard streams (#741)

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

authored by ehmicky · committed by GitHub · parent 17993a8 · Browse files · 10 files+306 added−93 removed
This commit

State

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

Diff stats

10 files+306 added−93 removed

  • tests:+197 added−72 removed
  • other:+109 added−21 removed

10 files+306 added−93 removed

modified:docs/transform.md+2 added
modified:lib/stdio/handle.js+2 added
modified:lib/stdio/lines.js+24 added-1 removed
1import {isUint8Array} from './utils.js';2import {willPipeStreams} from './pipe.js';33// Split chunks line-wise4// Split chunks line-wise for streams exposed to users like `childProcess.stdout`.5// Appending a noop transform in object mode is enough to do this, since every non-binary transform iterates line-wise.6export const handleStreamsLines = (stdioStreams, {lines}, isSync) => shouldSplitLines(stdioStreams, lines, isSync)7 ? [8 ...stdioStreams,9 {10 ...stdioStreams[0],11 type: 'generator',12 value: {transform: linesEndGenerator, objectMode: true},13 },14 ]15 : stdioStreams;1617const shouldSplitLines = (stdioStreams, lines, isSync) => stdioStreams[0].direction === 'output'18 && lines19 && !isSync20 && willPipeStreams(stdioStreams);2122const linesEndGenerator = async function * (chunks) {23 yield * chunks;24};2526// Split chunks line-wise for generators passed to the `std*` options27export const getLinesGenerator = (encoding, binary) => {28 if (binary) {29 return;30 }
70 unmodified lines
modified:test/helpers/generator.js+2 added-1 removed
37 unmodified lines
38});3940export const outputObjectGenerator = getOutputGenerator(foobarObject, true);4142export const getChunksGenerator = (chunks, objectMode) => ({42export const getChunksGenerator = (chunks, objectMode, binary) => ({43 async * transform(lines) {44 // eslint-disable-next-line no-unused-vars45 for await (const line of lines) {46 for (const chunk of chunks) {
3 unmodified lines
50 }51 }52 },53 objectMode,54 binary,55});
modified:test/stdio/encoding.js+40 added-19 removed
147 unmodified lines
148 const {stdout} = await execa('noop.js', {stdout: outputObjectGenerator, encoding: 'base64'});149 t.deepEqual(stdout, [foobarObject]);150});151152const testIgnoredEncoding = async (t, stdoutOption, isUndefined) => {153 const {stdout} = await execa('empty.js', {stdout: stdoutOption, encoding: 'base64'});152const testIgnoredEncoding = async (t, stdoutOption, isUndefined, options) => {153 const {stdout} = await execa('empty.js', {stdout: stdoutOption, ...options});154 t.is(stdout === undefined, isUndefined);155};156157const base64Options = {encoding: 'base64'};158const linesOptions = {lines: true};157test('Is ignored with other encodings and "ignore"', testIgnoredEncoding, 'ignore', true);158test('Is ignored with other encodings and ["ignore"]', testIgnoredEncoding, ['ignore'], true);159test('Is ignored with other encodings and "ipc"', testIgnoredEncoding, 'ipc', true);160test('Is ignored with other encodings and ["ipc"]', testIgnoredEncoding, ['ipc'], true);161test('Is ignored with other encodings and "inherit"', testIgnoredEncoding, 'inherit', true);162test('Is ignored with other encodings and ["inherit"]', testIgnoredEncoding, ['inherit'], true);163test('Is ignored with other encodings and 1', testIgnoredEncoding, 1, true);164test('Is ignored with other encodings and [1]', testIgnoredEncoding, [1], true);165test('Is ignored with other encodings and process.stdout', testIgnoredEncoding, process.stdout, true);166test('Is ignored with other encodings and [process.stdout]', testIgnoredEncoding, [process.stdout], true);167test('Is not ignored with other encodings and "pipe"', testIgnoredEncoding, 'pipe', false);168test('Is not ignored with other encodings and ["pipe"]', testIgnoredEncoding, ['pipe'], false);169test('Is not ignored with other encodings and "overlapped"', testIgnoredEncoding, 'overlapped', false);170test('Is not ignored with other encodings and ["overlapped"]', testIgnoredEncoding, ['overlapped'], false);171test('Is not ignored with other encodings and ["inherit", "pipe"]', testIgnoredEncoding, ['inherit', 'pipe'], false);172test('Is not ignored with other encodings and undefined', testIgnoredEncoding, undefined, false);173test('Is not ignored with other encodings and null', testIgnoredEncoding, null, false);159test('Is ignored with other encodings and "ignore"', testIgnoredEncoding, 'ignore', true, base64Options);160test('Is ignored with other encodings and ["ignore"]', testIgnoredEncoding, ['ignore'], true, base64Options);161test('Is ignored with other encodings and "ipc"', testIgnoredEncoding, 'ipc', true, base64Options);162test('Is ignored with other encodings and ["ipc"]', testIgnoredEncoding, ['ipc'], true, base64Options);163test('Is ignored with other encodings and "inherit"', testIgnoredEncoding, 'inherit', true, base64Options);164test('Is ignored with other encodings and ["inherit"]', testIgnoredEncoding, ['inherit'], true, base64Options);165test('Is ignored with other encodings and 1', testIgnoredEncoding, 1, true, base64Options);166test('Is ignored with other encodings and [1]', testIgnoredEncoding, [1], true, base64Options);167test('Is ignored with other encodings and process.stdout', testIgnoredEncoding, process.stdout, true, base64Options);168test('Is ignored with other encodings and [process.stdout]', testIgnoredEncoding, [process.stdout], true, base64Options);169test('Is not ignored with other encodings and "pipe"', testIgnoredEncoding, 'pipe', false, base64Options);170test('Is not ignored with other encodings and ["pipe"]', testIgnoredEncoding, ['pipe'], false, base64Options);171test('Is not ignored with other encodings and "overlapped"', testIgnoredEncoding, 'overlapped', false, base64Options);172test('Is not ignored with other encodings and ["overlapped"]', testIgnoredEncoding, ['overlapped'], false, base64Options);173test('Is not ignored with other encodings and ["inherit", "pipe"]', testIgnoredEncoding, ['inherit', 'pipe'], false, base64Options);174test('Is not ignored with other encodings and undefined', testIgnoredEncoding, undefined, false, base64Options);175test('Is not ignored with other encodings and null', testIgnoredEncoding, null, false, base64Options);176test('Is ignored with "lines: true" and "ignore"', testIgnoredEncoding, 'ignore', true, linesOptions);177test('Is ignored with "lines: true" and ["ignore"]', testIgnoredEncoding, ['ignore'], true, linesOptions);178test('Is ignored with "lines: true" and "ipc"', testIgnoredEncoding, 'ipc', true, linesOptions);179test('Is ignored with "lines: true" and ["ipc"]', testIgnoredEncoding, ['ipc'], true, linesOptions);180test('Is ignored with "lines: true" and "inherit"', testIgnoredEncoding, 'inherit', true, linesOptions);181test('Is ignored with "lines: true" and ["inherit"]', testIgnoredEncoding, ['inherit'], true, linesOptions);182test('Is ignored with "lines: true" and 1', testIgnoredEncoding, 1, true, linesOptions);183test('Is ignored with "lines: true" and [1]', testIgnoredEncoding, [1], true, linesOptions);184test('Is ignored with "lines: true" and process.stdout', testIgnoredEncoding, process.stdout, true, linesOptions);185test('Is ignored with "lines: true" and [process.stdout]', testIgnoredEncoding, [process.stdout], true, linesOptions);186test('Is not ignored with "lines: true" and "pipe"', testIgnoredEncoding, 'pipe', false, linesOptions);187test('Is not ignored with "lines: true" and ["pipe"]', testIgnoredEncoding, ['pipe'], false, linesOptions);188test('Is not ignored with "lines: true" and "overlapped"', testIgnoredEncoding, 'overlapped', false, linesOptions);189test('Is not ignored with "lines: true" and ["overlapped"]', testIgnoredEncoding, ['overlapped'], false, linesOptions);190test('Is not ignored with "lines: true" and ["inherit", "pipe"]', testIgnoredEncoding, ['inherit', 'pipe'], false, linesOptions);191test('Is not ignored with "lines: true" and undefined', testIgnoredEncoding, undefined, false, linesOptions);192test('Is not ignored with "lines: true" and null', testIgnoredEncoding, null, false, linesOptions);193test('Is ignored with "lines: true", other encodings and "ignore"', testIgnoredEncoding, 'ignore', true, {...base64Options, ...linesOptions});194test('Is not ignored with "lines: true", other encodings and "pipe"', testIgnoredEncoding, 'pipe', false, {...base64Options, ...linesOptions});
modified:test/stdio/lines.js+155 added-52 removed
1import {once} from 'node:events';2import {Writable} from 'node:stream';3import {scheduler} from 'node:timers/promises';4import test from 'ava';3import {execa} from '../../index.js';5import {execa, execaSync} from '../../index.js';6import {setFixtureDir} from '../helpers/fixtures-dir.js';5import {getStdio} from '../helpers/stdio.js';7import {fullStdio, getStdio} from '../helpers/stdio.js';8import {getChunksGenerator} from '../helpers/generator.js';9import {foobarObject} from '../helpers/input.js';1011setFixtureDir();1213const simpleChunk = ['aaa\nbbb\nccc'];14const simpleLines = ['aaa\n', 'bbb\n', 'ccc'];15const windowsChunk = ['aaa\r\nbbb\r\nccc'];16const windowsLines = ['aaa\r\n', 'bbb\r\n', 'ccc'];17const newlineEndChunk = ['aaa\nbbb\nccc\n'];18const newlineEndLines = ['aaa\n', 'bbb\n', 'ccc\n'];19const noNewlinesChunk = ['aaa'];20const noNewlinesChunks = ['aaa', 'bbb', 'ccc'];21const noNewlinesLines = ['aaabbbccc'];22const newlineChunk = ['\n'];23const newlinesChunk = ['\n\n\n'];24const newlinesLines = ['\n', '\n', '\n'];25const windowsNewlinesChunk = ['\r\n\r\n\r\n'];26const windowsNewlinesLines = ['\r\n', '\r\n', '\r\n'];27const runOverChunks = ['aaa\nb', 'b', 'b\nccc'];2829const bigLine = '.'.repeat(1e5);30const manyChunks = Array.from({length: 1e3}).fill('.');3132const inputGenerator = async function * (input, chunks) {
43 unmodified lines
76 t.is(input.join(''), serializeResult(stdio[index], isUint8Array, objectMode));77 t.deepEqual(lines, stringsToUint8Arrays(expectedLines, isUint8Array));78};7960test('Split string stdout - n newlines, 1 chunk', testLines, 1, ['aaa\nbbb\nccc'], ['aaa\n', 'bbb\n', 'ccc'], false, false);61test('Split string stderr - n newlines, 1 chunk', testLines, 2, ['aaa\nbbb\nccc'], ['aaa\n', 'bbb\n', 'ccc'], false, false);62test('Split string stdio[*] - n newlines, 1 chunk', testLines, 3, ['aaa\nbbb\nccc'], ['aaa\n', 'bbb\n', 'ccc'], false, false);63test('Split string stdout - no newline, n chunks', testLines, 1, ['aaa', 'bbb', 'ccc'], ['aaabbbccc'], false, false);64test('Split string stdout - 0 newlines, 1 chunk', testLines, 1, ['aaa'], ['aaa'], false, false);65test('Split string stdout - Windows newlines', testLines, 1, ['aaa\r\nbbb\r\nccc'], ['aaa\r\n', 'bbb\r\n', 'ccc'], false, false);66test('Split string stdout - chunk ends with newline', testLines, 1, ['aaa\nbbb\nccc\n'], ['aaa\n', 'bbb\n', 'ccc\n'], false, false);67test('Split string stdout - single newline', testLines, 1, ['\n'], ['\n'], false, false);68test('Split string stdout - only newlines', testLines, 1, ['\n\n\n'], ['\n', '\n', '\n'], false, false);69test('Split string stdout - only Windows newlines', testLines, 1, ['\r\n\r\n\r\n'], ['\r\n', '\r\n', '\r\n'], false, false);70test('Split string stdout - line split over multiple chunks', testLines, 1, ['aaa\nb', 'b', 'b\nccc'], ['aaa\n', 'bbb\n', 'ccc'], false, false);80test('Split string stdout - n newlines, 1 chunk', testLines, 1, simpleChunk, simpleLines, false, false);81test('Split string stderr - n newlines, 1 chunk', testLines, 2, simpleChunk, simpleLines, false, false);82test('Split string stdio[*] - n newlines, 1 chunk', testLines, 3, simpleChunk, simpleLines, false, false);83test('Split string stdout - no newline, n chunks', testLines, 1, noNewlinesChunks, noNewlinesLines, false, false);84test('Split string stdout - 0 newlines, 1 chunk', testLines, 1, noNewlinesChunk, noNewlinesChunk, false, false);85test('Split string stdout - Windows newlines', testLines, 1, windowsChunk, windowsLines, false, false);86test('Split string stdout - chunk ends with newline', testLines, 1, newlineEndChunk, newlineEndLines, false, false);87test('Split string stdout - single newline', testLines, 1, newlineChunk, newlineChunk, false, false);88test('Split string stdout - only newlines', testLines, 1, newlinesChunk, newlinesLines, false, false);89test('Split string stdout - only Windows newlines', testLines, 1, windowsNewlinesChunk, windowsNewlinesLines, false, false);90test('Split string stdout - line split over multiple chunks', testLines, 1, runOverChunks, simpleLines, false, false);91test('Split string stdout - 0 newlines, big line', testLines, 1, [bigLine], [bigLine], false, false);92test('Split string stdout - 0 newlines, many chunks', testLines, 1, manyChunks, [manyChunks.join('')], false, false);73test('Split Uint8Array stdout - n newlines, 1 chunk', testLines, 1, ['aaa\nbbb\nccc'], ['aaa\n', 'bbb\n', 'ccc'], true, false);74test('Split Uint8Array stderr - n newlines, 1 chunk', testLines, 2, ['aaa\nbbb\nccc'], ['aaa\n', 'bbb\n', 'ccc'], true, false);75test('Split Uint8Array stdio[*] - n newlines, 1 chunk', testLines, 3, ['aaa\nbbb\nccc'], ['aaa\n', 'bbb\n', 'ccc'], true, false);76test('Split Uint8Array stdout - no newline, n chunks', testLines, 1, ['aaa', 'bbb', 'ccc'], ['aaabbbccc'], true, false);77test('Split Uint8Array stdout - 0 newlines, 1 chunk', testLines, 1, ['aaa'], ['aaa'], true, false);78test('Split Uint8Array stdout - Windows newlines', testLines, 1, ['aaa\r\nbbb\r\nccc'], ['aaa\r\n', 'bbb\r\n', 'ccc'], true, false);79test('Split Uint8Array stdout - chunk ends with newline', testLines, 1, ['aaa\nbbb\nccc\n'], ['aaa\n', 'bbb\n', 'ccc\n'], true, false);80test('Split Uint8Array stdout - single newline', testLines, 1, ['\n'], ['\n'], true, false);81test('Split Uint8Array stdout - only newlines', testLines, 1, ['\n\n\n'], ['\n', '\n', '\n'], true, false);82test('Split Uint8Array stdout - only Windows newlines', testLines, 1, ['\r\n\r\n\r\n'], ['\r\n', '\r\n', '\r\n'], true, false);83test('Split Uint8Array stdout - line split over multiple chunks', testLines, 1, ['aaa\nb', 'b', 'b\nccc'], ['aaa\n', 'bbb\n', 'ccc'], true, false);93test('Split Uint8Array stdout - n newlines, 1 chunk', testLines, 1, simpleChunk, simpleLines, true, false);94test('Split Uint8Array stderr - n newlines, 1 chunk', testLines, 2, simpleChunk, simpleLines, true, false);95test('Split Uint8Array stdio[*] - n newlines, 1 chunk', testLines, 3, simpleChunk, simpleLines, true, false);96test('Split Uint8Array stdout - no newline, n chunks', testLines, 1, noNewlinesChunks, noNewlinesLines, true, false);97test('Split Uint8Array stdout - 0 newlines, 1 chunk', testLines, 1, noNewlinesChunk, noNewlinesChunk, true, false);98test('Split Uint8Array stdout - Windows newlines', testLines, 1, windowsChunk, windowsLines, true, false);99test('Split Uint8Array stdout - chunk ends with newline', testLines, 1, newlineEndChunk, newlineEndLines, true, false);100test('Split Uint8Array stdout - single newline', testLines, 1, newlineChunk, newlineChunk, true, false);101test('Split Uint8Array stdout - only newlines', testLines, 1, newlinesChunk, newlinesLines, true, false);102test('Split Uint8Array stdout - only Windows newlines', testLines, 1, windowsNewlinesChunk, windowsNewlinesLines, true, false);103test('Split Uint8Array stdout - line split over multiple chunks', testLines, 1, runOverChunks, simpleLines, true, false);104test('Split Uint8Array stdout - 0 newlines, big line', testLines, 1, [bigLine], [bigLine], true, false);105test('Split Uint8Array stdout - 0 newlines, many chunks', testLines, 1, manyChunks, [manyChunks.join('')], true, false);86test('Split string stdout - n newlines, 1 chunk, objectMode', testLines, 1, ['aaa\nbbb\nccc'], ['aaa\n', 'bbb\n', 'ccc'], false, true);87test('Split string stderr - n newlines, 1 chunk, objectMode', testLines, 2, ['aaa\nbbb\nccc'], ['aaa\n', 'bbb\n', 'ccc'], false, true);88test('Split string stdio[*] - n newlines, 1 chunk, objectMode', testLines, 3, ['aaa\nbbb\nccc'], ['aaa\n', 'bbb\n', 'ccc'], false, true);89test('Split string stdout - no newline, n chunks, objectMode', testLines, 1, ['aaa', 'bbb', 'ccc'], ['aaabbbccc'], false, true);90test('Split string stdout - 0 newlines, 1 chunk, objectMode', testLines, 1, ['aaa'], ['aaa'], false, true);91test('Split string stdout - Windows newlines, objectMode', testLines, 1, ['aaa\r\nbbb\r\nccc'], ['aaa\r\n', 'bbb\r\n', 'ccc'], false, true);92test('Split string stdout - chunk ends with newline, objectMode', testLines, 1, ['aaa\nbbb\nccc\n'], ['aaa\n', 'bbb\n', 'ccc\n'], false, true);93test('Split string stdout - single newline, objectMode', testLines, 1, ['\n'], ['\n'], false, true);94test('Split string stdout - only newlines, objectMode', testLines, 1, ['\n\n\n'], ['\n', '\n', '\n'], false, true);95test('Split string stdout - only Windows newlines, objectMode', testLines, 1, ['\r\n\r\n\r\n'], ['\r\n', '\r\n', '\r\n'], false, true);96test('Split string stdout - line split over multiple chunks, objectMode', testLines, 1, ['aaa\nb', 'b', 'b\nccc'], ['aaa\n', 'bbb\n', 'ccc'], false, true);106test('Split string stdout - n newlines, 1 chunk, objectMode', testLines, 1, simpleChunk, simpleLines, false, true);107test('Split string stderr - n newlines, 1 chunk, objectMode', testLines, 2, simpleChunk, simpleLines, false, true);108test('Split string stdio[*] - n newlines, 1 chunk, objectMode', testLines, 3, simpleChunk, simpleLines, false, true);109test('Split string stdout - no newline, n chunks, objectMode', testLines, 1, noNewlinesChunks, noNewlinesLines, false, true);110test('Split string stdout - 0 newlines, 1 chunk, objectMode', testLines, 1, noNewlinesChunk, noNewlinesChunk, false, true);111test('Split string stdout - Windows newlines, objectMode', testLines, 1, windowsChunk, windowsLines, false, true);112test('Split string stdout - chunk ends with newline, objectMode', testLines, 1, newlineEndChunk, newlineEndLines, false, true);113test('Split string stdout - single newline, objectMode', testLines, 1, newlineChunk, newlineChunk, false, true);114test('Split string stdout - only newlines, objectMode', testLines, 1, newlinesChunk, newlinesLines, false, true);115test('Split string stdout - only Windows newlines, objectMode', testLines, 1, windowsNewlinesChunk, windowsNewlinesLines, false, true);116test('Split string stdout - line split over multiple chunks, objectMode', testLines, 1, runOverChunks, simpleLines, false, true);117test('Split string stdout - 0 newlines, big line, objectMode', testLines, 1, [bigLine], [bigLine], false, true);118test('Split string stdout - 0 newlines, many chunks, objectMode', testLines, 1, manyChunks, [manyChunks.join('')], false, true);99test('Split Uint8Array stdout - n newlines, 1 chunk, objectMode', testLines, 1, ['aaa\nbbb\nccc'], ['aaa\n', 'bbb\n', 'ccc'], true, true);100test('Split Uint8Array stderr - n newlines, 1 chunk, objectMode', testLines, 2, ['aaa\nbbb\nccc'], ['aaa\n', 'bbb\n', 'ccc'], true, true);101test('Split Uint8Array stdio[*] - n newlines, 1 chunk, objectMode', testLines, 3, ['aaa\nbbb\nccc'], ['aaa\n', 'bbb\n', 'ccc'], true, true);102test('Split Uint8Array stdout - no newline, n chunks, objectMode', testLines, 1, ['aaa', 'bbb', 'ccc'], ['aaabbbccc'], true, true);103test('Split Uint8Array stdout - 0 newlines, 1 chunk, objectMode', testLines, 1, ['aaa'], ['aaa'], true, true);104test('Split Uint8Array stdout - Windows newlines, objectMode', testLines, 1, ['aaa\r\nbbb\r\nccc'], ['aaa\r\n', 'bbb\r\n', 'ccc'], true, true);105test('Split Uint8Array stdout - chunk ends with newline, objectMode', testLines, 1, ['aaa\nbbb\nccc\n'], ['aaa\n', 'bbb\n', 'ccc\n'], true, true);106test('Split Uint8Array stdout - single newline, objectMode', testLines, 1, ['\n'], ['\n'], true, true);107test('Split Uint8Array stdout - only newlines, objectMode', testLines, 1, ['\n\n\n'], ['\n', '\n', '\n'], true, true);108test('Split Uint8Array stdout - only Windows newlines, objectMode', testLines, 1, ['\r\n\r\n\r\n'], ['\r\n', '\r\n', '\r\n'], true, true);109test('Split Uint8Array stdout - line split over multiple chunks, objectMode', testLines, 1, ['aaa\nb', 'b', 'b\nccc'], ['aaa\n', 'bbb\n', 'ccc'], true, true);119test('Split Uint8Array stdout - n newlines, 1 chunk, objectMode', testLines, 1, simpleChunk, simpleLines, true, true);120test('Split Uint8Array stderr - n newlines, 1 chunk, objectMode', testLines, 2, simpleChunk, simpleLines, true, true);121test('Split Uint8Array stdio[*] - n newlines, 1 chunk, objectMode', testLines, 3, simpleChunk, simpleLines, true, true);122test('Split Uint8Array stdout - no newline, n chunks, objectMode', testLines, 1, noNewlinesChunks, noNewlinesLines, true, true);123test('Split Uint8Array stdout - 0 newlines, 1 chunk, objectMode', testLines, 1, noNewlinesChunk, noNewlinesChunk, true, true);124test('Split Uint8Array stdout - Windows newlines, objectMode', testLines, 1, windowsChunk, windowsLines, true, true);125test('Split Uint8Array stdout - chunk ends with newline, objectMode', testLines, 1, newlineEndChunk, newlineEndLines, true, true);126test('Split Uint8Array stdout - single newline, objectMode', testLines, 1, newlineChunk, newlineChunk, true, true);127test('Split Uint8Array stdout - only newlines, objectMode', testLines, 1, newlinesChunk, newlinesLines, true, true);128test('Split Uint8Array stdout - only Windows newlines, objectMode', testLines, 1, windowsNewlinesChunk, windowsNewlinesLines, true, true);129test('Split Uint8Array stdout - line split over multiple chunks, objectMode', testLines, 1, runOverChunks, simpleLines, true, true);130test('Split Uint8Array stdout - 0 newlines, big line, objectMode', testLines, 1, [bigLine], [bigLine], true, true);131test('Split Uint8Array stdout - 0 newlines, many chunks, objectMode', testLines, 1, manyChunks, [manyChunks.join('')], true, true);132133// eslint-disable-next-line max-params
8 unmodified lines
142 t.is(input.join(''), objectMode ? stdout.join('') : stdout);143 t.deepEqual(lines, expectedLines);144};145126test('Does not split lines when "binary" is true', testBinaryOption, true, ['aaa\nbbb\nccc'], ['aaa\nbbb\nccc'], false);127test('Splits lines when "binary" is false', testBinaryOption, false, ['aaa\nbbb\nccc'], ['aaa\n', 'bbb\n', 'ccc'], false);128test('Splits lines when "binary" is undefined', testBinaryOption, undefined, ['aaa\nbbb\nccc'], ['aaa\n', 'bbb\n', 'ccc'], false);129test('Does not split lines when "binary" is true, objectMode', testBinaryOption, true, ['aaa\nbbb\nccc'], ['aaa\nbbb\nccc'], true);130test('Splits lines when "binary" is false, objectMode', testBinaryOption, false, ['aaa\nbbb\nccc'], ['aaa\n', 'bbb\n', 'ccc'], true);131test('Splits lines when "binary" is undefined, objectMode', testBinaryOption, undefined, ['aaa\nbbb\nccc'], ['aaa\n', 'bbb\n', 'ccc'], true);146test('Does not split lines when "binary" is true', testBinaryOption, true, simpleChunk, simpleChunk, false);147test('Splits lines when "binary" is false', testBinaryOption, false, simpleChunk, simpleLines, false);148test('Splits lines when "binary" is undefined', testBinaryOption, undefined, simpleChunk, simpleLines, false);149test('Does not split lines when "binary" is true, objectMode', testBinaryOption, true, simpleChunk, simpleChunk, true);150test('Splits lines when "binary" is false, objectMode', testBinaryOption, false, simpleChunk, simpleLines, true);151test('Splits lines when "binary" is undefined, objectMode', testBinaryOption, undefined, simpleChunk, simpleLines, true);152153// eslint-disable-next-line max-params154const testStreamLines = async (t, index, input, expectedLines, isUint8Array) => {155 const {stdio} = await execa('noop-fd.js', [`${index}`, input], {156 ...fullStdio,157 lines: true,158 encoding: isUint8Array ? 'buffer' : 'utf8',159 });160 t.deepEqual(stdio[index], stringsToUint8Arrays(expectedLines, isUint8Array));161};162163test('"lines: true" splits lines, stdout, string', testStreamLines, 1, simpleChunk[0], simpleLines, false);164test('"lines: true" splits lines, stdout, Uint8Array', testStreamLines, 1, simpleChunk[0], simpleLines, true);165test('"lines: true" splits lines, stderr, string', testStreamLines, 2, simpleChunk[0], simpleLines, false);166test('"lines: true" splits lines, stderr, Uint8Array', testStreamLines, 2, simpleChunk[0], simpleLines, true);167test('"lines: true" splits lines, stdio[*], string', testStreamLines, 3, simpleChunk[0], simpleLines, false);168test('"lines: true" splits lines, stdio[*], Uint8Array', testStreamLines, 3, simpleChunk[0], simpleLines, true);169170const testStreamLinesNoop = async (t, lines, execaMethod) => {171 const {stdout} = await execaMethod('noop-fd.js', ['1', simpleChunk[0]], {lines});172 t.is(stdout, simpleChunk[0]);173};174175test('"lines: false" is a noop with execa()', testStreamLinesNoop, false, execa);176test('"lines: false" is a noop with execaSync()', testStreamLinesNoop, false, execaSync);177test('"lines: true" is a noop with execaSync()', testStreamLinesNoop, true, execaSync);178179const bigArray = Array.from({length: 1e5}).fill('.\n');180const bigString = bigArray.join('');181const bigStringNoNewlines = '.'.repeat(1e6);182183// eslint-disable-next-line max-params184const testStreamLinesGenerator = async (t, input, expectedLines, objectMode, binary) => {185 const {stdout} = await execa('noop.js', {lines: true, stdout: getChunksGenerator(input, objectMode, binary)});186 t.deepEqual(stdout, expectedLines);187};188189test('"lines: true" works with strings generators', testStreamLinesGenerator, simpleChunk, simpleLines, false, false);190test('"lines: true" works with strings generators, objectMode', testStreamLinesGenerator, simpleChunk, simpleLines, true, false);191test('"lines: true" works with strings generators, binary', testStreamLinesGenerator, simpleChunk, simpleLines, false, true);192test('"lines: true" works with strings generators, binary, objectMode', testStreamLinesGenerator, simpleChunk, simpleLines, true, true);193test('"lines: true" works with big strings generators', testStreamLinesGenerator, [bigString], bigArray, false, false);194test('"lines: true" works with big strings generators, objectMode', testStreamLinesGenerator, [bigString], bigArray, true, false);195test('"lines: true" works with big strings generators without newlines', testStreamLinesGenerator, [bigStringNoNewlines], [bigStringNoNewlines], false, false);196test('"lines: true" works with big strings generators without newlines, objectMode', testStreamLinesGenerator, [bigStringNoNewlines], [bigStringNoNewlines], true, false);197198test('"lines: true" is a noop with objects generators, objectMode', async t => {199 const {stdout} = await execa('noop.js', {lines: true, stdout: getChunksGenerator([foobarObject], true)});200 t.deepEqual(stdout, [foobarObject]);201});202203const singleLine = 'a\n';204205test('"lines: true" works with other encodings', async t => {206 const {stdout} = await execa('noop-fd.js', ['1', `${singleLine}${singleLine}`], {lines: true, encoding: 'base64'});207 const expectedLines = [singleLine, singleLine].map(line => btoa(line));208 t.not(btoa(`${singleLine}${singleLine}`), expectedLines.join(''));209 t.deepEqual(stdout, expectedLines);210});211212test('"lines: true" works with stream async iteration', async t => {213 const childProcess = execa('noop.js', {lines: true, stdout: getChunksGenerator(simpleChunk), buffer: false});214 const [stdout] = await Promise.all([childProcess.stdout.toArray(), childProcess]);215 t.deepEqual(stdout, simpleLines);216});217218test('"lines: true" works with stream "data" events', async t => {219 const childProcess = execa('noop.js', {lines: true, stdout: getChunksGenerator(simpleChunk), buffer: false});220 const [[firstLine]] = await Promise.all([once(childProcess.stdout, 'data'), childProcess]);221 t.is(firstLine, simpleLines[0]);222});223224test('"lines: true" works with writable streams targets', async t => {225 const lines = [];226 const writable = new Writable({227 write(line, encoding, done) {228 lines.push(line.toString());229 done();230 },231 });232 await execa('noop.js', {lines: true, stdout: [getChunksGenerator(simpleChunk), writable]});233 t.deepEqual(lines, simpleLines);234});
modified:index.d.ts+22 added-9 removed
206 unmodified lines
207 StreamOutputIgnored extends boolean,208 OptionsType extends CommonOptions = CommonOptions,209> = StreamOutputIgnored extends true210 ? undefined211 : StreamEncoding<IsObjectStream<StreamIndex, OptionsType>, OptionsType['encoding']>;211 : StreamEncoding<IsObjectStream<StreamIndex, OptionsType>, OptionsType['lines'], OptionsType['encoding']>;212213type StreamEncoding<214 IsObjectResult extends boolean,215 LinesOption extends CommonOptions['lines'],216 Encoding extends CommonOptions['encoding'],217> = IsObjectResult extends true ? unknown[]218 : LinesOption extends true219 ? Encoding extends 'buffer' ? Uint8Array[] : string[]217 : Encoding extends 'buffer' ? Uint8Array : string;220 : Encoding extends 'buffer' ? Uint8Array : string;221222// Type of `result.all`223type AllOutput<OptionsType extends Options = Options> = AllOutputProperty<OptionsType['all'], OptionsType>;224
153 unmodified lines
378 */379 readonly stdio?: StdioOptions<IsSync>;380381 /**382 Split `stdout` and `stderr` into lines.383 - `result.stdout`, `result.stderr`, `result.all` and `result.stdio` are arrays of lines.384 - `childProcess.stdout`, `childProcess.stderr`, `childProcess.all` and `childProcess.stdio` iterate over lines instead of arbitrary chunks.385 - Any stream passed to the `stdout`, `stderr` or `stdio` option receives lines instead of arbitrary chunks.386387 @default false388 */389 readonly lines?: IfAsync<IsSync, boolean>;390391 /**392 Setting this to `false` resolves the promise with the error instead of rejecting it.393394 @default true395 */
256 unmodified lines
652653 /**654 The output of the process on `stdout`.655643 This is `undefined` if the `stdout` option is set to [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the `stdout` option is a transform in object mode.656 This is `undefined` if the `stdout` option is set to [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the `lines` option is `true, or if the `stdout` option is a transform in object mode.657 */658 stdout: StdioOutput<'1', OptionsType>;659660 /**661 The output of the process on `stderr`.662650 This is `undefined` if the `stderr` option is set to [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the `stderr` option is a transform in object mode.663 This is `undefined` if the `stderr` option is set to [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the `lines` option is `true, or if the `stderr` option is a transform in object mode.664 */665 stderr: StdioOutput<'2', OptionsType>;666667 /**
52 unmodified lines
720 This is `undefined` if either:721 - the `all` option is `false` (default value)722 - both `stdout` and `stderr` options are set to [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)723711 This is an array if either the `stdout` or `stderr` option is a transform in object mode.724 This is an array if the `lines` option is `true, or if either the `stdout` or `stderr` option is a transform in object mode.725 */726 all: IfAsync<IsSync, AllOutput<OptionsType>>;727 // Workaround for a TypeScript bug: https://github.com/microsoft/TypeScript/issues/57062728} & {};
222 unmodified lines
951952/**953Same as `execa()` but synchronous.954942Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization` and `signal`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, an iterable or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.955Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization`, `signal` and `lines`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, an iterable or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.956957@param file - The program/script to execute, as a string or file URL958@param arguments - Arguments to pass to `file` on execution.959@returns A `childProcessResult` object
90 unmodified lines
10501051/**1052Same as `execaCommand()` but synchronous.10531041Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization` and `signal`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, an iterable or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1054Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization`, `signal` and `lines`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, an iterable or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.10551056@param command - The program/script to execute and its arguments.1057@returns A `childProcessResult` object1058@throws A `childProcessResult` error
48 unmodified lines
11071108 /**1109 Same as $\`command\` but synchronous.11101098 Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization` and `signal`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, an iterable or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1111 Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization`, `signal` and `lines`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, an iterable or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.11121113 @returns A `childProcessResult` object1114 @throws A `childProcessResult` error1115
43 unmodified lines
11591160 /**1161 Same as $\`command\` but synchronous.11621150 Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization` and `signal`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, an iterable or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1163 Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `serialization`, `signal` and `lines`. Also, the `stdin`, `stdout`, `stderr`, `stdio` and `input` options cannot be an array, an iterable or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.11641165 @returns A `childProcessResult` object1166 @throws A `childProcessResult` error1167
135 unmodified lines
modified:index.js+2 added
80 unmodified lines
81 windowsHide = true,82 verbose = verboseDefault,83 killSignal = 'SIGTERM',84 forceKillAfterDelay = true,85 lines = false,86 ...options87}) => ({88 ...options,89 maxBuffer,
11 unmodified lines
101 windowsHide,102 verbose,103 killSignal,104 forceKillAfterDelay,105 lines,106});107108// Prevent passing the `timeout` option directly to `child_process.spawn()`109const handleAsyncOptions = ({timeout, ...options}) => ({...options, timeoutDuration: timeout});
248 unmodified lines
modified:index.test-d.ts+37 added-1 removed
20 unmodified lines
21 type ExecaSyncError,22} from './index.js';2324type AnySyncChunk = string | Uint8Array | undefined;25type AnyChunk = AnySyncChunk | unknown[];25type AnyChunk = AnySyncChunk | string[] | Uint8Array[] | unknown[];26expectType<Readable | null>({} as ExecaChildProcess['stdout']);27expectType<Readable | null>({} as ExecaChildProcess['stderr']);28expectType<Readable | undefined>({} as ExecaChildProcess['all']);29expectType<AnyChunk>({} as ExecaReturnValue['stdout']);
115 unmodified lines
145 expectType<Uint8Array>(bufferResult.stderr);146 expectType<Uint8Array>(bufferResult.stdio[2]);147 expectType<Uint8Array>(bufferResult.all);148149 const linesResult = await execa('unicorns', {lines: true, all: true});150 expectType<string[]>(linesResult.stdout);151 expectType<string[]>(linesResult.stdio[1]);152 expectType<string[]>(linesResult.stderr);153 expectType<string[]>(linesResult.stdio[2]);154 expectType<string[]>(linesResult.all);155156 const linesBufferResult = await execa('unicorns', {lines: true, encoding: 'buffer', all: true});157 expectType<Uint8Array[]>(linesBufferResult.stdout);158 expectType<Uint8Array[]>(linesBufferResult.stdio[1]);159 expectType<Uint8Array[]>(linesBufferResult.stderr);160 expectType<Uint8Array[]>(linesBufferResult.stdio[2]);161 expectType<Uint8Array[]>(linesBufferResult.all);162163 const noBufferPromise = execa('unicorns', {buffer: false, all: true});164 expectType<Readable>(noBufferPromise.stdout);165 expectType<Readable>(noBufferPromise.stderr);166 expectType<Readable>(noBufferPromise.all);
167 unmodified lines
334335 const bufferFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe'], encoding: 'buffer'});336 expectType<Uint8Array>(bufferFd3Result.stdio[3]);337338 const linesFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe'], lines: true});339 expectType<string[]>(linesFd3Result.stdio[3]);340341 const linesBufferFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe'], lines: true, encoding: 'buffer'});342 expectType<Uint8Array[]>(linesBufferFd3Result.stdio[3]);343344 const noBufferFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe'], buffer: false});345 expectType<undefined>(noBufferFd3Result.stdio[3]);346347 const ignoreFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'ignore']});
95 unmodified lines
443 expectType<Uint8Array>(execaBufferError.stderr);444 expectType<Uint8Array>(execaBufferError.stdio[2]);445 expectType<Uint8Array>(execaBufferError.all);446447 const execaLinesError = error as ExecaError<{lines: true; all: true}>;448 expectType<string[]>(execaLinesError.stdout);449 expectType<string[]>(execaLinesError.stdio[1]);450 expectType<string[]>(execaLinesError.stderr);451 expectType<string[]>(execaLinesError.stdio[2]);452 expectType<string[]>(execaLinesError.all);453454 const execaLinesBufferError = error as ExecaError<{lines: true; encoding: 'buffer'; all: true}>;455 expectType<Uint8Array[]>(execaLinesBufferError.stdout);456 expectType<Uint8Array[]>(execaLinesBufferError.stdio[1]);457 expectType<Uint8Array[]>(execaLinesBufferError.stderr);458 expectType<Uint8Array[]>(execaLinesBufferError.stdio[2]);459 expectType<Uint8Array[]>(execaLinesBufferError.all);460461 const noBufferError = error as ExecaError<{buffer: false; all: true}>;462 expectType<undefined>(noBufferError.stdout);463 expectType<undefined>(noBufferError.stdio[1]);464 expectType<undefined>(noBufferError.stderr);
283 unmodified lines
748execa('unicorns', {execPath: fileUrl});749execaSync('unicorns', {execPath: fileUrl});750execa('unicorns', {buffer: false});751expectError(execaSync('unicorns', {buffer: false}));752execa('unicorns', {lines: false});753expectError(execaSync('unicorns', {lines: false}));754execa('unicorns', {input: ''});755execaSync('unicorns', {input: ''});756execa('unicorns', {input: new Uint8Array()});757execaSync('unicorns', {input: new Uint8Array()});
592 unmodified lines
modified:readme.md+20 added-10 removed
276 unmodified lines
277### execaSync(file, arguments?, options?)278279Same as [`execa()`](#execacommandcommand-options) but synchronous.280281Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`serialization`](#serialization) and [`signal`](#signal). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be an array, an iterable or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.281Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`serialization`](#serialization), [`signal`](#signal) and [`lines`](#lines). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be an array, an iterable or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.282283Returns or throws a [`childProcessResult`](#childProcessResult).284285### $.sync\`command\`286### $.s\`command\`287288Same as [$\`command\`](#command) but synchronous.289290Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`serialization`](#serialization) and [`signal`](#signal). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be an array, an iterable or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.290Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`serialization`](#serialization), [`signal`](#signal) and [`lines`](#lines). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be an array, an iterable or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.291292Returns or throws a [`childProcessResult`](#childProcessResult).293294### execaCommandSync(command, options?)295296Same as [`execaCommand()`](#execacommand-command-options) but synchronous.297298Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`serialization`](#serialization) and [`signal`](#signal). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be an array, an iterable or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.298Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`serialization`](#serialization), [`signal`](#signal) and [`lines`](#lines). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be an array, an iterable or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.299300Returns or throws a [`childProcessResult`](#childProcessResult).301302### Shell syntax
78 unmodified lines
381This is `undefined` when the process could not be spawned or was terminated by a [signal](#signal-1).382383#### stdout384385Type: `string | Uint8Array | unknown[] | undefined`385Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`386387The output of the process on `stdout`.388389This is `undefined` if the [`stdout`](#stdout-1) option is set to [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the `stdout` option is a [transform in object mode](docs/transform.md#object-mode).389This is `undefined` if the [`stdout`](#stdout-1) option is set to [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the [`lines` option](#lines) is `true, or if the `stdout` option is a [transform in object mode](docs/transform.md#object-mode).390391#### stderr392393Type: `string | Uint8Array | unknown[] | undefined`393Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`394395The output of the process on `stderr`.396397This is `undefined` if the [`stderr`](#stderr-1) option is set to [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the `stderr` option is a [transform in object mode](docs/transform.md#object-mode).397This is `undefined` if the [`stderr`](#stderr-1) option is set to [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). This is an array if the [`lines` option](#lines) is `true, or if the `stderr` option is a [transform in object mode](docs/transform.md#object-mode).398399#### all400401Type: `string | Uint8Array | unknown[] | undefined`401Type: `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`402403The output of the process with `stdout` and `stderr` [interleaved](#ensuring-all-output-is-interleaved).404405This is `undefined` if either:406- the [`all` option](#all-2) is `false` (the default value)407- both [`stdout`](#stdout-1) and [`stderr`](#stderr-1) options are set to [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)408409This is an array if either the `stdout` or `stderr` option is a [transform in object mode](docs/transform.md#object-mode).409This is an array if the [`lines` option](#lines) is `true, or if either the `stdout` or `stderr` option is a [transform in object mode](docs/transform.md#object-mode).410411#### stdio412413Type: `Array<string | Uint8Array | unknown[] | undefined>`413Type: `Array<string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined>`414415The output of the process on [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1) and [other file descriptors](#stdio-1).416417Items are `undefined` when their corresponding [`stdio`](#stdio-1) option is set to [`'inherit'`, `'ipc'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio). Items are arrays when their corresponding `stdio` option is a [transform in object mode](docs/transform.md#object-mode).
218 unmodified lines
636Default: `false`637638Add an `.all` property on the [promise](#all) and the [resolved value](#all-1). The property contains the output of the process with `stdout` and `stderr` [interleaved](#ensuring-all-output-is-interleaved).639640#### lines641642Type: `boolean`\643Default: `false`644645Split `stdout` and `stderr` into lines.646- [`result.stdout`](#stdout), [`result.stderr`](#stderr), [`result.all`](#all-1) and [`result.stdio`](#stdio) are arrays of lines.647- [`childProcess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout), [`childProcess.stderr`](https://nodejs.org/api/child_process.html#subprocessstderr), [`childProcess.all`](#all) and [`childProcess.stdio`](https://nodejs.org/api/child_process.html#subprocessstdio) iterate over lines instead of arbitrary chunks.648- Any stream passed to the [`stdout`](#stdout-1), [`stderr`](#stderr-1) or [`stdio`](#stdio-1) option receives lines instead of arbitrary chunks.649650#### reject651652Type: `boolean`\653Default: `true`
301 unmodified lines