Skip to content
Myr

Log IPC messages with `verbose: 'full'` (#1063)

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

authored by ehmicky · committed by GitHub · parent 55a33c2 · Browse files · 19 files+242 added−48 removed
This commit

State

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

Diff stats

19 files+242 added−48 removed

  • tests:+132 added−3 removed
  • other:+110 added−45 removed

19 files+242 added−48 removed

modified:docs/api.md+1 added-1 removed
908 unmodified lines
909_Default:_ `'none'`910911If `verbose` is `'short'`, prints the command on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)): its file, arguments, duration and (if it failed) error message.912913If `verbose` is `'full'`, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) and `stderr` are also printed.913If `verbose` is `'full'`, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)), `stderr` and [IPC messages](ipc.md) are also printed.914915By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).916917[More info.](debugging.md#verbose-mode)
167 unmodified lines
modified:docs/debugging.md+1 added-1 removed
modified:docs/output.md+1 added-1 removed
100 unmodified lines
101```102103## Stdout/stderr-specific options104105Some options are related to the subprocess output: [`verbose`](api.md#optionsverbose), [`lines`](api.md#optionslines), [`stripFinalNewline`](api.md#optionsstripfinalnewline), [`buffer`](api.md#optionsbuffer), [`maxBuffer`](api.md#optionsmaxbuffer). By default, those options apply to all [file descriptors](https://en.wikipedia.org/wiki/File_descriptor) ([`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)), [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)), and [others](#additional-file-descriptors)). A plain object can be passed instead to apply them to only `stdout`, `stderr`, [`fd3`](#additional-file-descriptors), etc.105Some options are related to the subprocess output: [`verbose`](api.md#optionsverbose), [`lines`](api.md#optionslines), [`stripFinalNewline`](api.md#optionsstripfinalnewline), [`buffer`](api.md#optionsbuffer), [`maxBuffer`](api.md#optionsmaxbuffer). By default, those options apply to all [file descriptors](https://en.wikipedia.org/wiki/File_descriptor) ([`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)), [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)), and [others](#additional-file-descriptors)) and [IPC messages](ipc.md). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `all` (both stdout and stderr), [`ipc`](ipc.md), [`fd3`](#additional-file-descriptors), etc.106107```js108// Same value for stdout and stderr109await execa({verbose: 'full'})`npm run build`;
66 unmodified lines
modified:lib/arguments/specific.js+6 added-2 removed
14 unmodified lines
15 return optionsCopy;16};1718export const normalizeFdSpecificOption = (options, optionName) => {19 const optionBaseArray = Array.from({length: getStdioLength(options)});19 const optionBaseArray = Array.from({length: getStdioLength(options) + 1});20 const optionArray = normalizeFdSpecificValue(options[optionName], optionBaseArray, optionName);21 return addDefaultValue(optionArray, optionName);22};23
26 unmodified lines
50 return fdName === 'all' ? 2 : 1;51};5253const parseFdName = (fdName, optionName, optionArray) => {54 if (fdName === 'ipc') {55 return [optionArray.length - 1];56 }5758 const fdNumber = parseFd(fdName);59 if (fdNumber === undefined || fdNumber === 0) {60 throw new TypeError(`"${optionName}.${fdName}" is invalid.57It must be "${optionName}.stdout", "${optionName}.stderr", "${optionName}.all", or "${optionName}.fd3", "${optionName}.fd4" (and so on).`);61It must be "${optionName}.stdout", "${optionName}.stderr", "${optionName}.all", "${optionName}.ipc", or "${optionName}.fd3", "${optionName}.fd4" (and so on).`);62 }6364 if (fdNumber >= optionArray.length) {65 throw new TypeError(`"${optionName}.${fdName}" is invalid: that file descriptor does not exist.
38 unmodified lines
modified:lib/ipc/get-each.js+17 added-13 removed
added:lib/ipc/messages.js+18 added
modified:lib/resolve/wait-subprocess.js+11 added-1 removed
2 unmodified lines
3import {throwOnTimeout} from '../terminate/timeout.js';4import {isStandardStream} from '../utils/standard-stream.js';5import {TRANSFORM_TYPES} from '../stdio/type.js';6import {getBufferedData} from '../io/contents.js';7import {waitForIpcMessages} from '../ipc/messages.js';8import {waitForAllStream} from './all-async.js';9import {waitForStdioStreams} from './stdio.js';10import {waitForExit, waitForSuccessfulExit} from './exit-async.js';11import {waitForStream} from './wait-stream.js';1213// Retrieve result of subprocess: exit code, signal, error, streams (stdout/stderr/all)14export const waitForSubprocessResult = async ({15 subprocess,15 options: {encoding, buffer, maxBuffer, lines, timeoutDuration: timeout, stripFinalNewline},16 options: {17 encoding,18 buffer,19 maxBuffer,20 lines,21 timeoutDuration: timeout,22 stripFinalNewline,23 ipc,24 },25 context,26 verboseInfo,27 fileDescriptors,28 originalStreams,
38 unmodified lines
67 {},68 waitForSuccessfulExit(exitPromise),69 Promise.all(stdioPromises),70 allPromise,71 waitForIpcMessages(subprocess, ipc, verboseInfo),72 ...originalPromises,73 ...customStreamsEndPromises,74 ]),75 onInternalError,
37 unmodified lines
added:lib/verbose/ipc.js+8 added
modified:lib/verbose/log.js+13 added
1import {writeFileSync} from 'node:fs';2import {inspect} from 'node:util';3import figures from 'figures';4import {gray} from 'yoctocolors';5import {escapeLines} from '../arguments/escape.js';67// Write synchronously to ensure lines are properly ordered and not interleaved with `stdout`8export const verboseLog = (string, verboseId, icon, color) => {9 const prefixedLines = addPrefix(string, verboseId, icon, color);
29 unmodified lines
39const ICONS = {40 command: '$',41 pipedCommand: '|',42 output: ' ',43 ipc: '*',44 error: figures.cross,45 warning: figures.warning,46 success: figures.tick,47};4849// Serialize any type to a line string, for logging50export const serializeLogMessage = message => {51 const messageString = typeof message === 'string' ? message : inspect(message);52 const escapedMessage = escapeLines(messageString);53 return escapedMessage.replaceAll('\t', ' '.repeat(TAB_SIZE));54};5556// Same as `util.inspect()`57const TAB_SIZE = 2;
modified:lib/verbose/output.js+4 added-12 removed
1import {inspect} from 'node:util';2import {escapeLines} from '../arguments/escape.js';1import {BINARY_ENCODINGS} from '../arguments/encoding-option.js';2import {TRANSFORM_TYPES} from '../stdio/type.js';5import {verboseLog} from './log.js';3import {verboseLog, serializeLogMessage} from './log.js';45// `ignore` opts-out of `verbose` for a specific stream.6// `ipc` cannot use piping.7// `inherit` would result in double printing.
13 unmodified lines
21const fdUsesVerbose = fdNumber => fdNumber === 1 || fdNumber === 2;2223const PIPED_STDIO_VALUES = new Set(['pipe', 'overlapped']);2427// `verbose` printing logic with async methods25// `verbose: 'full'` printing logic with async methods26export const logLines = async (linesIterable, stream, verboseInfo) => {27 for await (const line of linesIterable) {28 if (!isPipingStream(stream)) {29 logLine(line, verboseInfo);30 }31 }32};3336// `verbose` printing logic with sync methods34// `verbose: 'full'` printing logic with sync methods35export const logLinesSync = (linesArray, verboseInfo) => {36 for (const line of linesArray) {37 logLine(line, verboseInfo);38 }
9 unmodified lines
48const isPipingStream = stream => stream._readableState.pipes.length > 0;4950// When `verbose` is `full`, print stdout|stderr51const logLine = (line, {verboseId}) => {54 const lines = typeof line === 'string' ? line : inspect(line);55 const escapedLines = escapeLines(lines);56 const spacedLines = escapedLines.replaceAll('\t', ' '.repeat(TAB_SIZE));57 verboseLog(spacedLines, verboseId, 'output');52 verboseLog(serializeLogMessage(line), verboseId, 'output');53};5960// Same as `util.inspect()`61const TAB_SIZE = 2;
added:test/fixtures/ipc-send-forever.js+7 added
1#!/usr/bin/env node2import {sendMessage} from '../../index.js';3import {foobarString} from '../helpers/input.js';45await sendMessage(foobarString);67setTimeout(() => {}, 1e8);
added:test/fixtures/ipc-send-json.js+6 added
1#!/usr/bin/env node2import {argv} from 'node:process';3import {sendMessage} from '../../index.js';45const message = JSON.parse(argv[2]);6await sendMessage(message);
modified:test/fixtures/ipc-send.js+3 added-1 removed
1#!/usr/bin/env node2import {argv} from 'node:process';3import {sendMessage} from '../../index.js';4import {foobarString} from '../helpers/input.js';56const message = argv[2] || foobarString;5await sendMessage(foobarString);7await sendMessage(message);
modified:test/helpers/verbose.js+6 added
45 unmodified lines
46const isCommandLine = line => line.includes(' $ ') || line.includes(' | ');47export const getOutputLine = stderr => getOutputLines(stderr)[0];48export const getOutputLines = stderr => getNormalizedLines(stderr).filter(line => isOutputLine(line));49const isOutputLine = line => line.includes('] ');50export const getIpcLine = stderr => getIpcLines(stderr)[0];51export const getIpcLines = stderr => getNormalizedLines(stderr).filter(line => isIpcLine(line));52const isIpcLine = line => line.includes(' * ');53export const getErrorLine = stderr => getErrorLines(stderr)[0];54export const getErrorLines = stderr => getNormalizedLines(stderr).filter(line => isErrorLine(line));55const isErrorLine = line => (line.includes(' × ') || line.includes(' ‼ ')) && !isCompletionLine(line);56export const getCompletionLine = stderr => getCompletionLines(stderr)[0];
18 unmodified lines
75export const fdStderrFullOption = {stdout: 'none', stderr: 'full'};76export const fd3NoneOption = {stdout: 'full', fd3: 'none'};77export const fd3ShortOption = {stdout: 'none', fd3: 'short'};78export const fd3FullOption = {stdout: 'none', fd3: 'full'};79export const ipcNoneOption = {ipc: 'none'};80export const ipcShortOption = {ipc: 'short'};81export const ipcFullOption = {ipc: 'full'};
added:test/verbose/ipc.js+108 added
1import {on} from 'node:events';2import {inspect} from 'node:util';3import test from 'ava';4import {red} from 'yoctocolors';5import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6import {foobarString, foobarObject} from '../helpers/input.js';7import {nestedExecaAsync, parentExecaAsync} from '../helpers/nested.js';8import {9 getIpcLine,10 getIpcLines,11 testTimestamp,12 ipcNoneOption,13 ipcShortOption,14 ipcFullOption,15} from '../helpers/verbose.js';1617setFixtureDirectory();1819const testPrintIpc = async (t, verbose) => {20 const {stderr} = await parentExecaAsync('ipc-send.js', {ipc: true, verbose});21 t.is(getIpcLine(stderr), `${testTimestamp} [0] * ${foobarString}`);22};2324test('Prints IPC, verbose "full"', testPrintIpc, 'full');25test('Prints IPC, verbose "full", fd-specific', testPrintIpc, ipcFullOption);2627const testNoPrintIpc = async (t, verbose) => {28 const {stderr} = await parentExecaAsync('ipc-send.js', {ipc: true, verbose});29 t.is(getIpcLine(stderr), undefined);30};3132test('Does not print IPC, verbose default', testNoPrintIpc, undefined);33test('Does not print IPC, verbose "none"', testNoPrintIpc, 'none');34test('Does not print IPC, verbose "short"', testNoPrintIpc, 'short');35test('Does not print IPC, verbose default, fd-specific', testNoPrintIpc, {});36test('Does not print IPC, verbose "none", fd-specific', testNoPrintIpc, ipcNoneOption);37test('Does not print IPC, verbose "short", fd-specific', testNoPrintIpc, ipcShortOption);3839const testNoIpc = async (t, ipc) => {40 const subprocess = nestedExecaAsync('ipc-send.js', {ipc, verbose: 'full'});41 await t.throwsAsync(subprocess, {message: /sendMessage\(\) can only be used/});42 const {stderr} = await subprocess.parent;43 t.is(getIpcLine(stderr), undefined);44};4546test('Does not print IPC, ipc: false', testNoIpc, false);47test('Does not print IPC, ipc: default', testNoIpc, undefined);4849test('Prints objects from IPC', async t => {50 const {stderr} = await parentExecaAsync('ipc-send-json.js', [JSON.stringify(foobarObject)], {ipc: true, verbose: 'full'});51 t.is(getIpcLine(stderr), `${testTimestamp} [0] * ${inspect(foobarObject)}`);52});5354test('Prints multiline arrays from IPC', async t => {55 const bigArray = Array.from({length: 100}, (_, index) => index);56 const {stderr} = await parentExecaAsync('ipc-send-json.js', [JSON.stringify(bigArray)], {ipc: true, verbose: 'full'});57 const ipcLines = getIpcLines(stderr);58 t.is(ipcLines[0], `${testTimestamp} [0] * [`);59 t.is(ipcLines.at(-2), `${testTimestamp} [0] * 96, 97, 98, 99`);60 t.is(ipcLines.at(-1), `${testTimestamp} [0] * ]`);61});6263test('Does not quote spaces from IPC', async t => {64 const {stderr} = await parentExecaAsync('ipc-send.js', ['foo bar'], {ipc: true, verbose: 'full'});65 t.is(getIpcLine(stderr), `${testTimestamp} [0] * foo bar`);66});6768test('Does not quote newlines from IPC', async t => {69 const {stderr} = await parentExecaAsync('ipc-send.js', ['foo\nbar'], {ipc: true, verbose: 'full'});70 t.deepEqual(getIpcLines(stderr), [71 `${testTimestamp} [0] * foo`,72 `${testTimestamp} [0] * bar`,73 ]);74});7576test('Does not quote special punctuation from IPC', async t => {77 const {stderr} = await parentExecaAsync('ipc-send.js', ['%'], {ipc: true, verbose: 'full'});78 t.is(getIpcLine(stderr), `${testTimestamp} [0] * %`);79});8081test('Does not escape internal characters from IPC', async t => {82 const {stderr} = await parentExecaAsync('ipc-send.js', ['ã'], {ipc: true, verbose: 'full'});83 t.is(getIpcLine(stderr), `${testTimestamp} [0] * ã`);84});8586test('Strips color sequences from IPC', async t => {87 const {stderr} = await parentExecaAsync('ipc-send.js', [red(foobarString)], {ipc: true, verbose: 'full'}, {env: {FORCE_COLOR: '1'}});88 t.is(getIpcLine(stderr), `${testTimestamp} [0] * ${foobarString}`);89});9091test('Escapes control characters from IPC', async t => {92 const {stderr} = await parentExecaAsync('ipc-send.js', ['\u0001'], {ipc: true, verbose: 'full'});93 t.is(getIpcLine(stderr), `${testTimestamp} [0] * \\u0001`);94});9596test('Prints IPC progressively', async t => {97 const subprocess = parentExecaAsync('ipc-send-forever.js', {ipc: true, verbose: 'full'});98 for await (const chunk of on(subprocess.stderr, 'data')) {99 const ipcLine = getIpcLine(chunk.toString());100 if (ipcLine !== undefined) {101 t.is(ipcLine, `${testTimestamp} [0] * ${foobarString}`);102 break;103 }104 }105106 subprocess.kill();107 await t.throwsAsync(subprocess);108});
modified:test/verbose/start.js+2 added-2 removed
33 unmodified lines
34test('Prints command, verbose "full", sync', testPrintCommand, 'full', parentExecaSync);35test('Prints command, verbose "short", fd-specific, sync', testPrintCommand, fdShortOption, parentExecaSync);36test('Prints command, verbose "full", fd-specific, sync', testPrintCommand, fdFullOption, parentExecaSync);37test('Prints command, verbose "short", worker', testPrintCommand, 'short', parentWorker);38test('Prints command, verbose "full", work', testPrintCommand, 'full', parentWorker);38test('Prints command, verbose "full", worker', testPrintCommand, 'full', parentWorker);39test('Prints command, verbose "short", fd-specific, worker', testPrintCommand, fdShortOption, parentWorker);40test('Prints command, verbose "full", fd-specific, work', testPrintCommand, fdFullOption, parentWorker);40test('Prints command, verbose "full", fd-specific, worker', testPrintCommand, fdFullOption, parentWorker);4142const testNoPrintCommand = async (t, verbose, execaMethod) => {43 const {stderr} = await execaMethod('noop.js', [foobarString], {verbose});44 t.is(stderr, '');
78 unmodified lines
modified:test-d/arguments/specific.test-d.ts+12 added
8 unmodified lines
9await execa('unicorns', {maxBuffer: {all: 0}});10await execa('unicorns', {maxBuffer: {fd1: 0}});11await execa('unicorns', {maxBuffer: {fd2: 0}});12await execa('unicorns', {maxBuffer: {fd3: 0}});13await execa('unicorns', {maxBuffer: {ipc: 0}});14expectError(await execa('unicorns', {maxBuffer: {stdout: '0'}}));1516execaSync('unicorns', {maxBuffer: {}});17expectError(execaSync('unicorns', {maxBuffer: []}));
3 unmodified lines
21execaSync('unicorns', {maxBuffer: {all: 0}});22execaSync('unicorns', {maxBuffer: {fd1: 0}});23execaSync('unicorns', {maxBuffer: {fd2: 0}});24execaSync('unicorns', {maxBuffer: {fd3: 0}});25execaSync('unicorns', {maxBuffer: {ipc: 0}});26expectError(execaSync('unicorns', {maxBuffer: {stdout: '0'}}));2728await execa('unicorns', {verbose: {}});29expectError(await execa('unicorns', {verbose: []}));
3 unmodified lines
33await execa('unicorns', {verbose: {all: 'none'}});34await execa('unicorns', {verbose: {fd1: 'none'}});35await execa('unicorns', {verbose: {fd2: 'none'}});36await execa('unicorns', {verbose: {fd3: 'none'}});37await execa('unicorns', {verbose: {ipc: 'none'}});38expectError(await execa('unicorns', {verbose: {stdout: 'other'}}));3940execaSync('unicorns', {verbose: {}});41expectError(execaSync('unicorns', {verbose: []}));
3 unmodified lines
45execaSync('unicorns', {verbose: {all: 'none'}});46execaSync('unicorns', {verbose: {fd1: 'none'}});47execaSync('unicorns', {verbose: {fd2: 'none'}});48execaSync('unicorns', {verbose: {fd3: 'none'}});49execaSync('unicorns', {verbose: {ipc: 'none'}});50expectError(execaSync('unicorns', {verbose: {stdout: 'other'}}));5152await execa('unicorns', {stripFinalNewline: {}});53expectError(await execa('unicorns', {stripFinalNewline: []}));
3 unmodified lines
57await execa('unicorns', {stripFinalNewline: {all: true}});58await execa('unicorns', {stripFinalNewline: {fd1: true}});59await execa('unicorns', {stripFinalNewline: {fd2: true}});60await execa('unicorns', {stripFinalNewline: {fd3: true}});61await execa('unicorns', {stripFinalNewline: {ipc: true}});62expectError(await execa('unicorns', {stripFinalNewline: {stdout: 'true'}}));6364execaSync('unicorns', {stripFinalNewline: {}});65expectError(execaSync('unicorns', {stripFinalNewline: []}));
3 unmodified lines
69execaSync('unicorns', {stripFinalNewline: {all: true}});70execaSync('unicorns', {stripFinalNewline: {fd1: true}});71execaSync('unicorns', {stripFinalNewline: {fd2: true}});72execaSync('unicorns', {stripFinalNewline: {fd3: true}});73execaSync('unicorns', {stripFinalNewline: {ipc: true}});74expectError(execaSync('unicorns', {stripFinalNewline: {stdout: 'true'}}));7576await execa('unicorns', {lines: {}});77expectError(await execa('unicorns', {lines: []}));
3 unmodified lines
81await execa('unicorns', {lines: {all: true}});82await execa('unicorns', {lines: {fd1: true}});83await execa('unicorns', {lines: {fd2: true}});84await execa('unicorns', {lines: {fd3: true}});85await execa('unicorns', {lines: {ipc: true}});86expectError(await execa('unicorns', {lines: {stdout: 'true'}}));8788execaSync('unicorns', {lines: {}});89expectError(execaSync('unicorns', {lines: []}));
3 unmodified lines
93execaSync('unicorns', {lines: {all: true}});94execaSync('unicorns', {lines: {fd1: true}});95execaSync('unicorns', {lines: {fd2: true}});96execaSync('unicorns', {lines: {fd3: true}});97execaSync('unicorns', {lines: {ipc: true}});98expectError(execaSync('unicorns', {lines: {stdout: 'true'}}));99100await execa('unicorns', {buffer: {}});101expectError(await execa('unicorns', {buffer: []}));
3 unmodified lines
105await execa('unicorns', {buffer: {all: true}});106await execa('unicorns', {buffer: {fd1: true}});107await execa('unicorns', {buffer: {fd2: true}});108await execa('unicorns', {buffer: {fd3: true}});109await execa('unicorns', {buffer: {ipc: true}});110expectError(await execa('unicorns', {buffer: {stdout: 'true'}}));111112execaSync('unicorns', {buffer: {}});113expectError(execaSync('unicorns', {buffer: []}));
3 unmodified lines
117execaSync('unicorns', {buffer: {all: true}});118execaSync('unicorns', {buffer: {fd1: true}});119execaSync('unicorns', {buffer: {fd2: true}});120execaSync('unicorns', {buffer: {fd3: true}});121execaSync('unicorns', {buffer: {ipc: true}});122expectError(execaSync('unicorns', {buffer: {stdout: 'true'}}));123124expectError(await execa('unicorns', {preferLocal: {}}));125expectError(await execa('unicorns', {preferLocal: []}));
3 unmodified lines
129expectError(await execa('unicorns', {preferLocal: {all: 0}}));130expectError(await execa('unicorns', {preferLocal: {fd1: 0}}));131expectError(await execa('unicorns', {preferLocal: {fd2: 0}}));132expectError(await execa('unicorns', {preferLocal: {fd3: 0}}));133expectError(await execa('unicorns', {preferLocal: {ipc: 0}}));134expectError(await execa('unicorns', {preferLocal: {stdout: '0'}}));135136expectError(execaSync('unicorns', {preferLocal: {}}));137expectError(execaSync('unicorns', {preferLocal: []}));
3 unmodified lines
141expectError(execaSync('unicorns', {preferLocal: {all: 0}}));142expectError(execaSync('unicorns', {preferLocal: {fd1: 0}}));143expectError(execaSync('unicorns', {preferLocal: {fd2: 0}}));144expectError(execaSync('unicorns', {preferLocal: {fd3: 0}}));145expectError(execaSync('unicorns', {preferLocal: {ipc: 0}}));146expectError(execaSync('unicorns', {preferLocal: {stdout: '0'}}));147148expectType<string[]>(execaSync('unicorns', {lines: {stdout: true, fd1: false}}).stdout);149expectType<string[]>(execaSync('unicorns', {lines: {stdout: true, all: false}}).stdout);
10 unmodified lines
modified:types/arguments/options.d.ts+3 added-3 removed
212 unmodified lines
213214 /**215 If `verbose` is `'short'`, prints the command on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)): its file, arguments, duration and (if it failed) error message.216217 If `verbose` is `'full'`, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) and `stderr` are also printed.217 If `verbose` is `'full'`, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)), `stderr` and IPC messages are also printed.218219 By default, this applies to both `stdout` and `stderr`, but different values can also be passed.220221 @default 'none'
112 unmodified lines
334335/**336Subprocess options.337338Some options are related to the subprocess output: `verbose`, `lines`, `stripFinalNewline`, `buffer`, `maxBuffer`. By default, those options apply to all file descriptors (`stdout`, `stderr`, etc.). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `fd3`, etc.338Some options are related to the subprocess output: `verbose`, `lines`, `stripFinalNewline`, `buffer`, `maxBuffer`. By default, those options apply to all file descriptors (`stdout`, `stderr`, etc.). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `all` (both stdout and stderr), `ipc`, `fd3`, etc.339340@example341342```
8 unmodified lines
351352/**353Subprocess options, with synchronous methods.354355Some options are related to the subprocess output: `verbose`, `lines`, `stripFinalNewline`, `buffer`, `maxBuffer`. By default, those options apply to all file descriptors (`stdout`, `stderr`, etc.). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `fd3`, etc.355Some options are related to the subprocess output: `verbose`, `lines`, `stripFinalNewline`, `buffer`, `maxBuffer`. By default, those options apply to all file descriptors (`stdout`, `stderr`, etc.). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `all` (both stdout and stderr), `ipc`, `fd3`, etc.356357@example358359```
13 unmodified lines
modified:types/arguments/specific.d.ts+15 added-11 removed
2 unmodified lines
3// Options which can be fd-specific like `{verbose: {stdout: 'none', stderr: 'full'}}`4export type FdGenericOption<OptionType> = OptionType | GenericOptionObject<OptionType>;56type GenericOptionObject<OptionType> = {7 readonly [FdName in FromOption]?: OptionType7 readonly [FdName in GenericFromOption]?: OptionType8};910type GenericFromOption = FromOption | 'ipc';1112// Retrieve fd-specific option's value13export type FdSpecificOption<14 GenericOption extends FdGenericOption<unknown>,15 FdNumber extends string,
3 unmodified lines
1920type FdSpecificObjectOption<21 GenericOption extends GenericOptionObject<unknown>,22 FdNumber extends string,21> = keyof GenericOption extends FromOption23> = keyof GenericOption extends GenericFromOption24 ? FdNumberToFromOption<FdNumber, keyof GenericOption> extends never25 ? undefined26 : GenericOption[FdNumberToFromOption<FdNumber, keyof GenericOption>]27 : GenericOption;2829type FdNumberToFromOption<30 FdNumber extends string,29 FromOptions extends FromOption,31 GenericOptionKeys extends GenericFromOption,32> = FdNumber extends '1'31 ? 'stdout' extends FromOptions33 ? 'stdout' extends GenericOptionKeys34 ? 'stdout'33 : 'fd1' extends FromOptions35 : 'fd1' extends GenericOptionKeys36 ? 'fd1'35 : 'all' extends FromOptions37 : 'all' extends GenericOptionKeys38 ? 'all'39 : never40 : FdNumber extends '2'39 ? 'stderr' extends FromOptions41 ? 'stderr' extends GenericOptionKeys42 ? 'stderr'41 : 'fd2' extends FromOptions43 : 'fd2' extends GenericOptionKeys44 ? 'fd2'43 : 'all' extends FromOptions45 : 'all' extends GenericOptionKeys46 ? 'all'47 : never46 : `fd${FdNumber}` extends FromOptions48 : `fd${FdNumber}` extends GenericOptionKeys49 ? `fd${FdNumber}`50 : 'ipc' extends GenericOptionKeys51 ? 'ipc'48 : never;52 : never;