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
Provenance
- Commit
839c2fe- Tree
f123b4f- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
55a33c2
19 files changed+242 added−48 removed
modified:docs/api.md+1 added-1 removed
908 unmodified lines909 _Default:_ `'none'`910 911 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.912 913-If `verbose` is `'full'`, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) and `stderr` are also printed.913+If `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.914 915 By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).916 917 [More info.](debugging.md#verbose-mode)167 unmodified linesmodified:docs/debugging.md+1 added-1 removed
55 unmodified lines5657585960606162636449 unmodified lines55 unmodified lines```
### Full mode
When the [`verbose`](api.md#optionsverbose) option is `'full'`, the subprocess' [`stdout` and `stderr`](output.md) are also logged. Both are printed on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)).When the [`verbose`](api.md#optionsverbose) option is `'full'`, the subprocess' [`stdout`, `stderr`](output.md) and [IPC messages](ipc.md) are also logged. They are all printed on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)).
The output is not logged if either:- The [`stdout`](api.md#optionsstdout)/[`stderr`](api.md#optionsstderr) option is [`'ignore'`](output.md#ignore-output) or [`'inherit'`](output.md#terminal-output).- The `stdout`/`stderr` is redirected to [a stream](streams.md#output), [a file](output.md#file-output), [a file descriptor](output.md#terminal-output), or [another subprocess](pipe.md).49 unmodified linesmodified:docs/output.md+1 added-1 removed
100 unmodified lines101 ```102 103 ## Stdout/stderr-specific options104 105-Some 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.105+Some 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.106 107 ```js108 // Same value for stdout and stderr109 await execa({verbose: 'full'})`npm run build`;66 unmodified linesmodified:lib/arguments/specific.js+6 added-2 removed
14 unmodified lines15 return optionsCopy;16 };17 18 export 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 lines50 return fdName === 'all' ? 2 : 1;51 };52 53 const parseFdName = (fdName, optionName, optionArray) => {54+ if (fdName === 'ipc') {55+ return [optionArray.length - 1];56+ }57+58 const fdNumber = parseFd(fdName);59 if (fdNumber === undefined || fdNumber === 0) {60 throw new TypeError(`"${optionName}.${fdName}" is invalid.57-It must be "${optionName}.stdout", "${optionName}.stderr", "${optionName}.all", or "${optionName}.fd3", "${optionName}.fd4" (and so on).`);61+It must be "${optionName}.stdout", "${optionName}.stderr", "${optionName}.all", "${optionName}.ipc", or "${optionName}.fd3", "${optionName}.fd4" (and so on).`);62 }63 64 if (fdNumber >= optionArray.length) {65 throw new TypeError(`"${optionName}.${fdName}" is invalid: that file descriptor does not exist.38 unmodified linesmodified:lib/ipc/get-each.js+17 added-13 removed
12345567891011121314151617181112131920212216232418192021252627282930273132333435363738394037414243444540414647import {once, on} from 'node:events';import {validateIpcOption, validateConnection} from './validation.js';
// Like `[sub]process.on('message')` but promise-basedexport const getEachMessage = function ({anyProcess, isSubprocess, ipc}) {export const getEachMessage = ({anyProcess, isSubprocess, ipc}) => loopOnMessages({ anyProcess, isSubprocess, ipc, shouldAwait: !isSubprocess,});
// Same but used internallyexport const loopOnMessages = ({anyProcess, isSubprocess, ipc, shouldAwait}) => { const methodName = 'getEachMessage'; validateIpcOption(methodName, isSubprocess, ipc); validateConnection(methodName, isSubprocess, anyProcess.channel !== null);
const controller = new AbortController(); stopOnExit(anyProcess, isSubprocess, controller);
return iterateOnMessages(anyProcess, isSubprocess, controller); stopOnExit(anyProcess, controller); return iterateOnMessages(anyProcess, shouldAwait, controller);};
const stopOnExit = async (anyProcess, isSubprocess, controller) => {const stopOnExit = async (anyProcess, controller) => { try { const onDisconnect = once(anyProcess, 'disconnect', {signal: controller.signal}); await (isSubprocess ? onDisconnect : Promise.race([onDisconnect, anyProcess])); await once(anyProcess, 'disconnect', {signal: controller.signal}); } catch {} finally { controller.abort(); }};
const iterateOnMessages = async function * (anyProcess, isSubprocess, controller) {const iterateOnMessages = async function * (anyProcess, shouldAwait, controller) { try { for await (const [message] of on(anyProcess, 'message', {signal: controller.signal})) { yield message; } } catch (error) { if (!controller.signal.aborted) { throw error; } } finally { if (!isSubprocess) { controller.abort();
if (shouldAwait) { await anyProcess; }
controller.abort(); }};added:lib/ipc/messages.js+18 added
123456789101112131415161718import {shouldLogIpc, logIpcMessage} from '../verbose/ipc.js';import {loopOnMessages} from './get-each.js';
// Iterate through IPC messages sent by the subprocessexport const waitForIpcMessages = async (subprocess, ipc, verboseInfo) => { if (!ipc || !shouldLogIpc(verboseInfo)) { return; }
for await (const message of loopOnMessages({ anyProcess: subprocess, isSubprocess: false, ipc, shouldAwait: false, })) { logIpcMessage(message, verboseInfo); }};modified:lib/resolve/wait-subprocess.js+11 added-1 removed
2 unmodified lines3 import {throwOnTimeout} from '../terminate/timeout.js';4 import {isStandardStream} from '../utils/standard-stream.js';5 import {TRANSFORM_TYPES} from '../stdio/type.js';6 import {getBufferedData} from '../io/contents.js';7+import {waitForIpcMessages} from '../ipc/messages.js';8 import {waitForAllStream} from './all-async.js';9 import {waitForStdioStreams} from './stdio.js';10 import {waitForExit, waitForSuccessfulExit} from './exit-async.js';11 import {waitForStream} from './wait-stream.js';12 13 // Retrieve result of subprocess: exit code, signal, error, streams (stdout/stderr/all)14 export 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 lines67 {},68 waitForSuccessfulExit(exitPromise),69 Promise.all(stdioPromises),70 allPromise,71+ waitForIpcMessages(subprocess, ipc, verboseInfo),72 ...originalPromises,73 ...customStreamsEndPromises,74 ]),75 onInternalError,37 unmodified linesadded:lib/verbose/ipc.js+8 added
12345678import {verboseLog, serializeLogMessage} from './log.js';
// When `verbose` is `'full'`, print IPC messages from the subprocessexport const shouldLogIpc = ({verbose}) => verbose.at(-1) === 'full';
export const logIpcMessage = (message, {verboseId}) => { verboseLog(serializeLogMessage(message), verboseId, 'ipc');};modified:lib/verbose/log.js+13 added
1 import {writeFileSync} from 'node:fs';2+import {inspect} from 'node:util';3 import figures from 'figures';4 import {gray} from 'yoctocolors';5+import {escapeLines} from '../arguments/escape.js';6 7 // Write synchronously to ensure lines are properly ordered and not interleaved with `stdout`8 export const verboseLog = (string, verboseId, icon, color) => {9 const prefixedLines = addPrefix(string, verboseId, icon, color);29 unmodified lines39 const ICONS = {40 command: '$',41 pipedCommand: '|',42 output: ' ',43+ ipc: '*',44 error: figures.cross,45 warning: figures.warning,46 success: figures.tick,47 };48+49+// Serialize any type to a line string, for logging50+export 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+};55+56+// Same as `util.inspect()`57+const TAB_SIZE = 2;modified:lib/verbose/output.js+4 added-12 removed
1-import {inspect} from 'node:util';2-import {escapeLines} from '../arguments/escape.js';1 import {BINARY_ENCODINGS} from '../arguments/encoding-option.js';2 import {TRANSFORM_TYPES} from '../stdio/type.js';5-import {verboseLog} from './log.js';3+import {verboseLog, serializeLogMessage} from './log.js';4 5 // `ignore` opts-out of `verbose` for a specific stream.6 // `ipc` cannot use piping.7 // `inherit` would result in double printing.13 unmodified lines21 const fdUsesVerbose = fdNumber => fdNumber === 1 || fdNumber === 2;22 23 const PIPED_STDIO_VALUES = new Set(['pipe', 'overlapped']);24 27-// `verbose` printing logic with async methods25+// `verbose: 'full'` printing logic with async methods26 export const logLines = async (linesIterable, stream, verboseInfo) => {27 for await (const line of linesIterable) {28 if (!isPipingStream(stream)) {29 logLine(line, verboseInfo);30 }31 }32 };33 36-// `verbose` printing logic with sync methods34+// `verbose: 'full'` printing logic with sync methods35 export const logLinesSync = (linesArray, verboseInfo) => {36 for (const line of linesArray) {37 logLine(line, verboseInfo);38 }9 unmodified lines48 const isPipingStream = stream => stream._readableState.pipes.length > 0;49 50 // When `verbose` is `full`, print stdout|stderr51 const 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 };59-60-// Same as `util.inspect()`61-const TAB_SIZE = 2;added:test/fixtures/ipc-send-forever.js+7 added
1+#!/usr/bin/env node2+import {sendMessage} from '../../index.js';3+import {foobarString} from '../helpers/input.js';4+5+await sendMessage(foobarString);6+7+setTimeout(() => {}, 1e8);added:test/fixtures/ipc-send-json.js+6 added
1+#!/usr/bin/env node2+import {argv} from 'node:process';3+import {sendMessage} from '../../index.js';4+5+const message = JSON.parse(argv[2]);6+await sendMessage(message);modified:test/fixtures/ipc-send.js+3 added-1 removed
1 #!/usr/bin/env node2+import {argv} from 'node:process';3 import {sendMessage} from '../../index.js';4 import {foobarString} from '../helpers/input.js';5 6+const message = argv[2] || foobarString;5-await sendMessage(foobarString);7+await sendMessage(message);modified:test/helpers/verbose.js+6 added
45 unmodified lines46 const isCommandLine = line => line.includes(' $ ') || line.includes(' | ');47 export const getOutputLine = stderr => getOutputLines(stderr)[0];48 export const getOutputLines = stderr => getNormalizedLines(stderr).filter(line => isOutputLine(line));49 const isOutputLine = line => line.includes('] ');50+export const getIpcLine = stderr => getIpcLines(stderr)[0];51+export const getIpcLines = stderr => getNormalizedLines(stderr).filter(line => isIpcLine(line));52+const isIpcLine = line => line.includes(' * ');53 export const getErrorLine = stderr => getErrorLines(stderr)[0];54 export const getErrorLines = stderr => getNormalizedLines(stderr).filter(line => isErrorLine(line));55 const isErrorLine = line => (line.includes(' × ') || line.includes(' ‼ ')) && !isCompletionLine(line);56 export const getCompletionLine = stderr => getCompletionLines(stderr)[0];18 unmodified lines75 export const fdStderrFullOption = {stdout: 'none', stderr: 'full'};76 export const fd3NoneOption = {stdout: 'full', fd3: 'none'};77 export const fd3ShortOption = {stdout: 'none', fd3: 'short'};78 export const fd3FullOption = {stdout: 'none', fd3: 'full'};79+export const ipcNoneOption = {ipc: 'none'};80+export const ipcShortOption = {ipc: 'short'};81+export const ipcFullOption = {ipc: 'full'};added:test/verbose/ipc.js+108 added
1+import {on} from 'node:events';2+import {inspect} from 'node:util';3+import test from 'ava';4+import {red} from 'yoctocolors';5+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6+import {foobarString, foobarObject} from '../helpers/input.js';7+import {nestedExecaAsync, parentExecaAsync} from '../helpers/nested.js';8+import {9+ getIpcLine,10+ getIpcLines,11+ testTimestamp,12+ ipcNoneOption,13+ ipcShortOption,14+ ipcFullOption,15+} from '../helpers/verbose.js';16+17+setFixtureDirectory();18+19+const testPrintIpc = async (t, verbose) => {20+ const {stderr} = await parentExecaAsync('ipc-send.js', {ipc: true, verbose});21+ t.is(getIpcLine(stderr), `${testTimestamp} [0] * ${foobarString}`);22+};23+24+test('Prints IPC, verbose "full"', testPrintIpc, 'full');25+test('Prints IPC, verbose "full", fd-specific', testPrintIpc, ipcFullOption);26+27+const testNoPrintIpc = async (t, verbose) => {28+ const {stderr} = await parentExecaAsync('ipc-send.js', {ipc: true, verbose});29+ t.is(getIpcLine(stderr), undefined);30+};31+32+test('Does not print IPC, verbose default', testNoPrintIpc, undefined);33+test('Does not print IPC, verbose "none"', testNoPrintIpc, 'none');34+test('Does not print IPC, verbose "short"', testNoPrintIpc, 'short');35+test('Does not print IPC, verbose default, fd-specific', testNoPrintIpc, {});36+test('Does not print IPC, verbose "none", fd-specific', testNoPrintIpc, ipcNoneOption);37+test('Does not print IPC, verbose "short", fd-specific', testNoPrintIpc, ipcShortOption);38+39+const 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+};45+46+test('Does not print IPC, ipc: false', testNoIpc, false);47+test('Does not print IPC, ipc: default', testNoIpc, undefined);48+49+test('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+});53+54+test('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+});62+63+test('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+});67+68+test('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+});75+76+test('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+});80+81+test('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+});85+86+test('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+});90+91+test('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+});95+96+test('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+ }105+106+ subprocess.kill();107+ await t.throwsAsync(subprocess);108+});modified:test/verbose/start.js+2 added-2 removed
33 unmodified lines34 test('Prints command, verbose "full", sync', testPrintCommand, 'full', parentExecaSync);35 test('Prints command, verbose "short", fd-specific, sync', testPrintCommand, fdShortOption, parentExecaSync);36 test('Prints command, verbose "full", fd-specific, sync', testPrintCommand, fdFullOption, parentExecaSync);37 test('Prints command, verbose "short", worker', testPrintCommand, 'short', parentWorker);38-test('Prints command, verbose "full", work', testPrintCommand, 'full', parentWorker);38+test('Prints command, verbose "full", worker', testPrintCommand, 'full', parentWorker);39 test('Prints command, verbose "short", fd-specific, worker', testPrintCommand, fdShortOption, parentWorker);40-test('Prints command, verbose "full", fd-specific, work', testPrintCommand, fdFullOption, parentWorker);40+test('Prints command, verbose "full", fd-specific, worker', testPrintCommand, fdFullOption, parentWorker);41 42 const testNoPrintCommand = async (t, verbose, execaMethod) => {43 const {stderr} = await execaMethod('noop.js', [foobarString], {verbose});44 t.is(stderr, '');78 unmodified linesmodified:test-d/arguments/specific.test-d.ts+12 added
8 unmodified lines9 await execa('unicorns', {maxBuffer: {all: 0}});10 await execa('unicorns', {maxBuffer: {fd1: 0}});11 await execa('unicorns', {maxBuffer: {fd2: 0}});12 await execa('unicorns', {maxBuffer: {fd3: 0}});13+await execa('unicorns', {maxBuffer: {ipc: 0}});14 expectError(await execa('unicorns', {maxBuffer: {stdout: '0'}}));15 16 execaSync('unicorns', {maxBuffer: {}});17 expectError(execaSync('unicorns', {maxBuffer: []}));3 unmodified lines21 execaSync('unicorns', {maxBuffer: {all: 0}});22 execaSync('unicorns', {maxBuffer: {fd1: 0}});23 execaSync('unicorns', {maxBuffer: {fd2: 0}});24 execaSync('unicorns', {maxBuffer: {fd3: 0}});25+execaSync('unicorns', {maxBuffer: {ipc: 0}});26 expectError(execaSync('unicorns', {maxBuffer: {stdout: '0'}}));27 28 await execa('unicorns', {verbose: {}});29 expectError(await execa('unicorns', {verbose: []}));3 unmodified lines33 await execa('unicorns', {verbose: {all: 'none'}});34 await execa('unicorns', {verbose: {fd1: 'none'}});35 await execa('unicorns', {verbose: {fd2: 'none'}});36 await execa('unicorns', {verbose: {fd3: 'none'}});37+await execa('unicorns', {verbose: {ipc: 'none'}});38 expectError(await execa('unicorns', {verbose: {stdout: 'other'}}));39 40 execaSync('unicorns', {verbose: {}});41 expectError(execaSync('unicorns', {verbose: []}));3 unmodified lines45 execaSync('unicorns', {verbose: {all: 'none'}});46 execaSync('unicorns', {verbose: {fd1: 'none'}});47 execaSync('unicorns', {verbose: {fd2: 'none'}});48 execaSync('unicorns', {verbose: {fd3: 'none'}});49+execaSync('unicorns', {verbose: {ipc: 'none'}});50 expectError(execaSync('unicorns', {verbose: {stdout: 'other'}}));51 52 await execa('unicorns', {stripFinalNewline: {}});53 expectError(await execa('unicorns', {stripFinalNewline: []}));3 unmodified lines57 await execa('unicorns', {stripFinalNewline: {all: true}});58 await execa('unicorns', {stripFinalNewline: {fd1: true}});59 await execa('unicorns', {stripFinalNewline: {fd2: true}});60 await execa('unicorns', {stripFinalNewline: {fd3: true}});61+await execa('unicorns', {stripFinalNewline: {ipc: true}});62 expectError(await execa('unicorns', {stripFinalNewline: {stdout: 'true'}}));63 64 execaSync('unicorns', {stripFinalNewline: {}});65 expectError(execaSync('unicorns', {stripFinalNewline: []}));3 unmodified lines69 execaSync('unicorns', {stripFinalNewline: {all: true}});70 execaSync('unicorns', {stripFinalNewline: {fd1: true}});71 execaSync('unicorns', {stripFinalNewline: {fd2: true}});72 execaSync('unicorns', {stripFinalNewline: {fd3: true}});73+execaSync('unicorns', {stripFinalNewline: {ipc: true}});74 expectError(execaSync('unicorns', {stripFinalNewline: {stdout: 'true'}}));75 76 await execa('unicorns', {lines: {}});77 expectError(await execa('unicorns', {lines: []}));3 unmodified lines81 await execa('unicorns', {lines: {all: true}});82 await execa('unicorns', {lines: {fd1: true}});83 await execa('unicorns', {lines: {fd2: true}});84 await execa('unicorns', {lines: {fd3: true}});85+await execa('unicorns', {lines: {ipc: true}});86 expectError(await execa('unicorns', {lines: {stdout: 'true'}}));87 88 execaSync('unicorns', {lines: {}});89 expectError(execaSync('unicorns', {lines: []}));3 unmodified lines93 execaSync('unicorns', {lines: {all: true}});94 execaSync('unicorns', {lines: {fd1: true}});95 execaSync('unicorns', {lines: {fd2: true}});96 execaSync('unicorns', {lines: {fd3: true}});97+execaSync('unicorns', {lines: {ipc: true}});98 expectError(execaSync('unicorns', {lines: {stdout: 'true'}}));99 100 await execa('unicorns', {buffer: {}});101 expectError(await execa('unicorns', {buffer: []}));3 unmodified lines105 await execa('unicorns', {buffer: {all: true}});106 await execa('unicorns', {buffer: {fd1: true}});107 await execa('unicorns', {buffer: {fd2: true}});108 await execa('unicorns', {buffer: {fd3: true}});109+await execa('unicorns', {buffer: {ipc: true}});110 expectError(await execa('unicorns', {buffer: {stdout: 'true'}}));111 112 execaSync('unicorns', {buffer: {}});113 expectError(execaSync('unicorns', {buffer: []}));3 unmodified lines117 execaSync('unicorns', {buffer: {all: true}});118 execaSync('unicorns', {buffer: {fd1: true}});119 execaSync('unicorns', {buffer: {fd2: true}});120 execaSync('unicorns', {buffer: {fd3: true}});121+execaSync('unicorns', {buffer: {ipc: true}});122 expectError(execaSync('unicorns', {buffer: {stdout: 'true'}}));123 124 expectError(await execa('unicorns', {preferLocal: {}}));125 expectError(await execa('unicorns', {preferLocal: []}));3 unmodified lines129 expectError(await execa('unicorns', {preferLocal: {all: 0}}));130 expectError(await execa('unicorns', {preferLocal: {fd1: 0}}));131 expectError(await execa('unicorns', {preferLocal: {fd2: 0}}));132 expectError(await execa('unicorns', {preferLocal: {fd3: 0}}));133+expectError(await execa('unicorns', {preferLocal: {ipc: 0}}));134 expectError(await execa('unicorns', {preferLocal: {stdout: '0'}}));135 136 expectError(execaSync('unicorns', {preferLocal: {}}));137 expectError(execaSync('unicorns', {preferLocal: []}));3 unmodified lines141 expectError(execaSync('unicorns', {preferLocal: {all: 0}}));142 expectError(execaSync('unicorns', {preferLocal: {fd1: 0}}));143 expectError(execaSync('unicorns', {preferLocal: {fd2: 0}}));144 expectError(execaSync('unicorns', {preferLocal: {fd3: 0}}));145+expectError(execaSync('unicorns', {preferLocal: {ipc: 0}}));146 expectError(execaSync('unicorns', {preferLocal: {stdout: '0'}}));147 148 expectType<string[]>(execaSync('unicorns', {lines: {stdout: true, fd1: false}}).stdout);149 expectType<string[]>(execaSync('unicorns', {lines: {stdout: true, all: false}}).stdout);10 unmodified linesmodified:types/arguments/options.d.ts+3 added-3 removed
212 unmodified lines213 214 /**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.216 217- 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.218 219 By default, this applies to both `stdout` and `stderr`, but different values can also be passed.220 221 @default 'none'112 unmodified lines334 335 /**336 Subprocess options.337 338-Some 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.338+Some 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.339 340 @example341 342 ```8 unmodified lines351 352 /**353 Subprocess options, with synchronous methods.354 355-Some 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.355+Some 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.356 357 @example358 359 ```13 unmodified linesmodified:types/arguments/specific.d.ts+15 added-11 removed
2 unmodified lines3 // Options which can be fd-specific like `{verbose: {stdout: 'none', stderr: 'full'}}`4 export type FdGenericOption<OptionType> = OptionType | GenericOptionObject<OptionType>;5 6 type GenericOptionObject<OptionType> = {7- readonly [FdName in FromOption]?: OptionType7+ readonly [FdName in GenericFromOption]?: OptionType8 };9 10+type GenericFromOption = FromOption | 'ipc';11+12 // Retrieve fd-specific option's value13 export type FdSpecificOption<14 GenericOption extends FdGenericOption<unknown>,15 FdNumber extends string,3 unmodified lines19 20 type 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;28 29 type 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;