Rename `result.ipc` to `result.ipcOutput` (#1075)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent 587b490 · Browse files · 26 files·+159 added−159 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
26 files+159 added−159 removed
- tests:+75 added−75 removed
- other:+84 added−84 removed
Provenance
- Commit
ae9b360- Tree
e83cd62- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
587b490
26 files changed+159 added−159 removed
modified:docs/api.md+1 added-1 removed
465 unmodified lines466 Items are arrays when their corresponding `stdio` option is a [transform in object mode](transform.md#object-mode).467 468 [More info.](output.md#additional-file-descriptors)469 470-### result.ipc470+### result.ipcOutput471 472 _Type_: [`Message[]`](ipc.md#message-type)473 474 All the messages [sent by the subprocess](#sendmessagemessage) to the current process.632 unmodified linesmodified:docs/execution.md+1 added-1 removed
124 unmodified linesExpand all1251261271281291291301311321334 unmodified lines124 unmodified linesExpand all- The [`stdin`](api.md#optionsstdin), [`stdout`](api.md#optionsstdout), [`stderr`](api.md#optionsstderr) and [`stdio`](api.md#optionsstdio) options cannot be [`'overlapped'`](api.md#optionsstdout), an [async iterable](lines.md#progressive-splitting), an async [transform](transform.md), a [`Duplex`](transform.md#duplextransform-streams), nor a [web stream](streams.md#web-streams). Node.js streams can be passed but only if either they [have a file descriptor](streams.md#file-descriptors), or the [`input`](api.md#optionsinput) option is used.- Signal termination: [`subprocess.kill()`](api.md#subprocesskillerror), [`subprocess.pid`](api.md#subprocesspid), [`cleanup`](api.md#optionscleanup) option, [`cancelSignal`](api.md#optionscancelsignal) option, [`forceKillAfterDelay`](api.md#optionsforcekillafterdelay) option.- Piping multiple subprocesses: [`subprocess.pipe()`](api.md#subprocesspipefile-arguments-options).- [`subprocess.iterable()`](lines.md#progressive-splitting).- [`ipc`](api.md#optionsipc) and [`serialization`](api.md#optionsserialization) options.- [IPC](ipc.md): [`sendMessage()`](api.md#sendmessagemessage), [`getOneMessage()`](api.md#getonemessage), [`getEachMessage()`](api.md#geteachmessage), [`result.ipcOutput`](output.md#any-output-type), [`ipc`](api.md#optionsipc) option, [`serialization`](api.md#optionsserialization) option, [`ipcInput`](input.md#any-input-type) option.- [`result.all`](api.md#resultall) is not interleaved.- [`detached`](api.md#optionsdetached) option.- The [`maxBuffer`](api.md#optionsmaxbuffer) option is always measured in bytes, not in characters, [lines](api.md#optionslines) nor [objects](transform.md#object-mode). Also, it ignores transforms and the [`encoding`](api.md#optionsencoding) option.
4 unmodified linesmodified:docs/ipc.md+5 added-5 removed
67 unmodified lines68 ```69 70 ## Retrieve all messages71 72-The [`result.ipc`](api.md#resultipc) array contains all the messages sent by the subprocess. In many situations, this is simpler than using [`subprocess.getOneMessage()`](api.md#subprocessgetonemessage) and [`subprocess.getEachMessage()`](api.md#subprocessgeteachmessage).72+The [`result.ipcOutput`](api.md#resultipcoutput) array contains all the messages sent by the subprocess. In many situations, this is simpler than using [`subprocess.getOneMessage()`](api.md#subprocessgetonemessage) and [`subprocess.getEachMessage()`](api.md#subprocessgeteachmessage).73 74 ```js75 // main.js76 import {execaNode} from 'execa';77 78-const {ipc} = await execaNode`build.js`;79-console.log(ipc[0]); // {kind: 'start', timestamp: date}80-console.log(ipc[1]); // {kind: 'stop', timestamp: date}78+const {ipcOutput} = await execaNode`build.js`;79+console.log(ipcOutput[0]); // {kind: 'start', timestamp: date}80+console.log(ipcOutput[1]); // {kind: 'stop', timestamp: date}81 ```82 83 ```js84 // build.js39 unmodified lines124 ## Debugging125 126 When the [`verbose`](api.md#optionsverbose) option is `'full'`, the IPC messages sent by the subprocess to the current process are [printed on the console](debugging.md#full-mode).127 128-Also, when the subprocess [failed](errors.md#subprocess-failure), [`error.ipc`](api.md) contains all the messages sent by the subprocess. Those are also shown at the end of the [error message](errors.md#error-message).128+Also, when the subprocess [failed](errors.md#subprocess-failure), [`error.ipcOutput`](api.md) contains all the messages sent by the subprocess. Those are also shown at the end of the [error message](errors.md#error-message).129 130 <hr>131 132 [**Next**: 🐛 Debugging](debugging.md)\2 unmodified linesmodified:docs/output.md+7 added-7 removed
55 unmodified lines56 ```57 58 ## Any output type59 60-If the subprocess uses Node.js, [IPC](ipc.md) can be used to return [almost any type](ipc.md#message-type) from the subprocess. The [`result.ipc`](api.md#resultipc) array contains all the messages sent by the subprocess.60+If the subprocess uses Node.js, [IPC](ipc.md) can be used to return [almost any type](ipc.md#message-type) from the subprocess. The [`result.ipcOutput`](api.md#resultipcoutput) array contains all the messages sent by the subprocess.61 62 ```js63 // main.js64 import {execaNode} from 'execa';65 66-const {ipc} = await execaNode`build.js`;67-console.log(ipc[0]); // {kind: 'start', timestamp: date}68-console.log(ipc[1]); // {kind: 'stop', timestamp: date}66+const {ipcOutput} = await execaNode`build.js`;67+console.log(ipcOutput[0]); // {kind: 'start', timestamp: date}68+console.log(ipcOutput[1]); // {kind: 'stop', timestamp: date}69 ```70 71 ```js72 // build.js88 unmodified lines161 ## Big output162 163 To prevent high memory consumption, a maximum output size can be set using the [`maxBuffer`](api.md#optionsmaxbuffer) option. It defaults to 100MB.164 165-When this threshold is hit, the subprocess fails and [`error.isMaxBuffer`](api.md#errorismaxbuffer) becomes `true`. The truncated output is still available using [`error.stdout`](api.md#resultstdout), [`error.stderr`](api.md#resultstderr) and [`error.ipc`](api.md#resultipc).165+When this threshold is hit, the subprocess fails and [`error.isMaxBuffer`](api.md#errorismaxbuffer) becomes `true`. The truncated output is still available using [`error.stdout`](api.md#resultstdout), [`error.stderr`](api.md#resultstderr) and [`error.ipcOutput`](api.md#resultipcoutput).166 167 This is measured:168 - By default: in [characters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length).169 - If the [`encoding`](binary.md#encoding) option is `'buffer'`: in bytes.170 - If the [`lines`](lines.md#simple-splitting) option is `true`: in lines.171 - If a [transform in object mode](transform.md#object-mode) is used: in objects.172-- With [`error.ipc`](ipc.md#retrieve-all-messages): in messages.172+- With [`error.ipcOutput`](ipc.md#retrieve-all-messages): in messages.173 174 ```js175 try {176 await execa({maxBuffer: 1_000_000})`npm run build`;9 unmodified lines186 ```187 188 ## Low memory189 190-When the [`buffer`](api.md#optionsbuffer) option is `false`, [`result.stdout`](api.md#resultstdout), [`result.stderr`](api.md#resultstderr), [`result.all`](api.md#resultall), [`result.stdio[*]`](api.md#resultstdio) and [`result.ipc`](api.md#resultipc) properties are empty.190+When the [`buffer`](api.md#optionsbuffer) option is `false`, [`result.stdout`](api.md#resultstdout), [`result.stderr`](api.md#resultstderr), [`result.all`](api.md#resultall), [`result.stdio[*]`](api.md#resultstdio) and [`result.ipcOutput`](api.md#resultipcoutput) properties are empty.191 192 This prevents high memory consumption when the output is big. However, the output must be either ignored, [redirected](#file-output), [streamed](streams.md) or [listened to](ipc.md#listening-to-messages). If streamed, this should be done right away to avoid missing any data.193 194 <hr>4 unmodified linesmodified:lib/io/max-buffer.js+3 added-3 removed
33 unmodified lines34 35 return 'characters';36 };37 38-// Check the `maxBuffer` option with `result.ipc`39-export const checkIpcMaxBuffer = (subprocess, ipcMessages, maxBuffer) => {40- if (ipcMessages.length !== maxBuffer) {38+// Check the `maxBuffer` option with `result.ipcOutput`39+export const checkIpcMaxBuffer = (subprocess, ipcOutput, maxBuffer) => {40+ if (ipcOutput.length !== maxBuffer) {41 return;42 }43 44 disconnect(subprocess);45 unmodified linesmodified:lib/ipc/buffer-messages.js+9 added-9 removed
122345667891011111213141515161718192021222323242526272829303132333433343536373838394041424243import {checkIpcMaxBuffer} from '../io/max-buffer.js';import {shouldLogIpc, logIpcMessage} from '../verbose/ipc.js';import {shouldLogIpc, logIpcOutput} from '../verbose/ipc.js';import {loopOnMessages} from './get-each.js';
// Iterate through IPC messages sent by the subprocessexport const waitForIpcMessages = async ({export const waitForIpcOutput = async ({ subprocess, buffer: bufferArray, maxBuffer: maxBufferArray, ipc, ipcMessages, ipcOutput, verboseInfo,}) => { if (!ipc) { return ipcMessages; return ipcOutput; }
const isVerbose = shouldLogIpc(verboseInfo); const buffer = bufferArray.at(-1); const maxBuffer = maxBufferArray.at(-1);
if (!isVerbose && !buffer) { return ipcMessages; return ipcOutput; }
for await (const message of loopOnMessages({ anyProcess: subprocess, isSubprocess: false, ipc, shouldAwait: false, })) { if (buffer) { checkIpcMaxBuffer(subprocess, ipcMessages, maxBuffer); ipcMessages.push(message); checkIpcMaxBuffer(subprocess, ipcOutput, maxBuffer); ipcOutput.push(message); }
if (isVerbose) { logIpcMessage(message, verboseInfo); logIpcOutput(message, verboseInfo); } }
return ipcMessages; return ipcOutput;};modified:lib/methods/main-async.js+5 added-5 removed
135 unmodified lines136 errorInfo,137 [exitCode, signal],138 stdioResults,139 allResult,140- ipcMessages,140+ ipcOutput,141 ] = await waitForSubprocessResult({142 subprocess,143 options,144 context,13 unmodified lines158 exitCode,159 signal,160 stdio,161 all,162- ipcMessages,162+ ipcOutput,163 context,164 options,165 command,166 escapedCommand,1 unmodified line168 });169 return handleResult(result, verboseInfo, options);170 };171 172-const getAsyncResult = ({errorInfo, exitCode, signal, stdio, all, ipcMessages, context, options, command, escapedCommand, startTime}) => 'error' in errorInfo172+const getAsyncResult = ({errorInfo, exitCode, signal, stdio, all, ipcOutput, context, options, command, escapedCommand, startTime}) => 'error' in errorInfo173 ? makeError({174 error: errorInfo.error,175 command,176 escapedCommand,3 unmodified lines180 exitCode,181 signal,182 stdio,183 all,184- ipcMessages,184+ ipcOutput,185 options,186 startTime,187 isSync: false,188 })1 unmodified line190 command,191 escapedCommand,192 stdio,193 all,194- ipcMessages,194+ ipcOutput,195 options,196 startTime,197 });modified:lib/methods/main-sync.js+2 added-2 removed
143 unmodified lines144 command,145 escapedCommand,146 stdio,147 all,148- ipcMessages: [],148+ ipcOutput: [],149 options,150 startTime,151 })152 : makeError({6 unmodified lines159 exitCode,160 signal,161 stdio,162 all,163- ipcMessages: [],163+ ipcOutput: [],164 options,165 startTime,166 isSync: true,167 });modified:lib/resolve/wait-subprocess.js+5 added-5 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/buffer-messages.js';7+import {waitForIpcOutput} from '../ipc/buffer-messages.js';8 import {sendIpcInput} from '../ipc/ipc-input.js';9 import {waitForAllStream} from './all-async.js';10 import {waitForStdioStreams} from './stdio.js';11 import {waitForExit, waitForSuccessfulExit} from './exit-async.js';47 unmodified lines59 stripFinalNewline,60 verboseInfo,61 streamInfo,62 });63- const ipcMessages = [];63+ const ipcOutput = [];64 const originalPromises = waitForOriginalStreams(originalStreams, subprocess, streamInfo);65 const customStreamsEndPromises = waitForCustomStreamsEnd(fileDescriptors, streamInfo);66 67 try {2 unmodified lines70 {},71 waitForSuccessfulExit(exitPromise),72 Promise.all(stdioPromises),73 allPromise,74- waitForIpcMessages({74+ waitForIpcOutput({75 subprocess,76 buffer,77 maxBuffer,78 ipc,79- ipcMessages,79+ ipcOutput,80 verboseInfo,81 }),82 sendIpcInput(subprocess, ipcInput),83 ...originalPromises,8 unmodified lines92 {error},93 exitPromise,94 Promise.all(stdioPromises.map(stdioPromise => getBufferedData(stdioPromise))),95 getBufferedData(allPromise),96- ipcMessages,96+ ipcOutput,97 Promise.allSettled(originalPromises),98 Promise.allSettled(customStreamsEndPromises),99 ]);100 }24 unmodified linesmodified:lib/return/message.js+2 added-2 removed
8 unmodified lines9 // Computes `error.message`, `error.shortMessage` and `error.originalMessage`10 export const createMessages = ({11 stdio,12 all,13- ipcMessages,13+ ipcOutput,14 originalError,15 signal,16 signalDescription,17 exitCode,25 unmodified lines43 const message = [44 shortMessage,45 ...messageStdio,46 ...stdio.slice(3),47- ipcMessages.map(ipcMessage => serializeIpcMessage(ipcMessage)).join('\n'),47+ ipcOutput.map(ipcMessage => serializeIpcMessage(ipcMessage)).join('\n'),48 ]49 .map(messagePart => escapeLines(stripFinalNewline(serializeMessagePart(messagePart))))50 .filter(Boolean)51 .join('\n\n');62 unmodified linesmodified:lib/return/result.js+8 added-8 removed
7 unmodified lines8 command,9 escapedCommand,10 stdio,11 all,12- ipcMessages,12+ ipcOutput,13 options: {cwd},14 startTime,15 }) => omitUndefinedProperties({16 command,9 unmodified lines26 stdout: stdio[1],27 stderr: stdio[2],28 all,29 stdio,30- ipc: ipcMessages,30+ ipcOutput,31 pipedFrom: [],32 });33 34 // Object returned on subprocess failure before spawning13 unmodified lines48 timedOut: false,49 isCanceled: false,50 isMaxBuffer: false,51 stdio: Array.from({length: fileDescriptors.length}),52- ipcMessages: [],52+ ipcOutput: [],53 options,54 isSync,55 });56 9 unmodified lines66 exitCode: rawExitCode,67 signal: rawSignal,68 stdio,69 all,70- ipcMessages,70+ ipcOutput,71 options: {timeoutDuration, timeout = timeoutDuration, cwd, maxBuffer},72 isSync,73 }) => {74 const {exitCode, signal, signalDescription} = normalizeExitPayload(rawExitCode, rawSignal);75 const {originalMessage, shortMessage, message} = createMessages({76 stdio,77 all,78- ipcMessages,78+ ipcOutput,79 originalError,80 signal,81 signalDescription,82 exitCode,18 unmodified lines101 signal,102 signalDescription,103 stdio,104 all,105- ipcMessages,105+ ipcOutput,106 cwd,107 originalMessage,108 shortMessage,109 }));12 unmodified lines122 signal,123 signalDescription,124 stdio,125 all,126- ipcMessages,126+ ipcOutput,127 cwd,128 originalMessage,129 shortMessage,130 }) => omitUndefinedProperties({15 unmodified lines146 stdout: stdio[1],147 stderr: stdio[2],148 all,149 stdio,150- ipc: ipcMessages,150+ ipcOutput,151 pipedFrom: [],152 });153 154 const omitUndefinedProperties = result => Object.fromEntries(Object.entries(result).filter(([, value]) => value !== undefined));9 unmodified linesmodified:lib/verbose/ipc.js+1 added-1 removed
1 unmodified line2 3 // When `verbose` is `'full'`, print IPC messages from the subprocess4 export const shouldLogIpc = ({verbose}) => verbose.at(-1) === 'full';5 6-export const logIpcMessage = (message, {verboseId}) => {6+export const logIpcOutput = (message, {verboseId}) => {7 verboseLog(serializeLogMessage(message), verboseId, 'ipc');8 };modified:test/io/max-buffer.js+6 added-6 removed
265 unmodified lines266 t.true(failed);267 t.false(isMaxBuffer);268 });269 270-test('maxBuffer works with result.ipc', async t => {270+test('maxBuffer works with result.ipcOutput', async t => {271 const {272 isMaxBuffer,273 shortMessage,274 message,275 stderr,276- ipc,276+ ipcOutput,277 } = await t.throwsAsync(execa('ipc-send-twice-wait.js', {ipc: true, maxBuffer: {ipc: 1}}));278 t.true(isMaxBuffer);279 t.is(shortMessage, 'Command\'s IPC output was larger than 1 messages: ipc-send-twice-wait.js\nmaxBuffer exceeded');280 t.true(message.endsWith(`\n\n${foobarString}`));281 t.true(stderr.includes('Error: getOneMessage() could not complete'));282- t.deepEqual(ipc, [foobarString]);282+ t.deepEqual(ipcOutput, [foobarString]);283 });284 285-test('maxBuffer is ignored with result.ipc if buffer is false', async t => {285+test('maxBuffer is ignored with result.ipcOutput if buffer is false', async t => {286 const subprocess = execa('ipc-send-twice-wait.js', {ipc: true, maxBuffer: {ipc: 1}, buffer: false});287 t.is(await subprocess.getOneMessage(), foobarString);288 t.is(await subprocess.getOneMessage(), foobarString);289 await subprocess.sendMessage(foobarString);290 291- const {ipc} = await subprocess;292- t.deepEqual(ipc, []);291+ const {ipcOutput} = await subprocess;292+ t.deepEqual(ipcOutput, []);293 });modified:test/ipc/buffer-messages.js+28 added-28 removed
4 unmodified lines5 6 setFixtureDirectory();7 8 const testResultIpc = async (t, options) => {9- const {ipc} = await execa('ipc-send-twice.js', {...options, ipc: true});10- t.deepEqual(ipc, foobarArray);9+ const {ipcOutput} = await execa('ipc-send-twice.js', {...options, ipc: true});10+ t.deepEqual(ipcOutput, foobarArray);11 };12 13-test('Sets result.ipc', testResultIpc, {});14-test('Sets result.ipc, fd-specific buffer', testResultIpc, {buffer: {stdout: false}});13+test('Sets result.ipcOutput', testResultIpc, {});14+test('Sets result.ipcOutput, fd-specific buffer', testResultIpc, {buffer: {stdout: false}});15 16 const testResultNoBuffer = async (t, options) => {17- const {ipc} = await execa('ipc-send.js', {...options, ipc: true});18- t.deepEqual(ipc, []);17+ const {ipcOutput} = await execa('ipc-send.js', {...options, ipc: true});18+ t.deepEqual(ipcOutput, []);19 };20 21-test('Sets empty result.ipc if buffer is false', testResultNoBuffer, {buffer: false});22-test('Sets empty result.ipc if buffer is false, fd-specific buffer', testResultNoBuffer, {buffer: {ipc: false}});21+test('Sets empty result.ipcOutput if buffer is false', testResultNoBuffer, {buffer: false});22+test('Sets empty result.ipcOutput if buffer is false, fd-specific buffer', testResultNoBuffer, {buffer: {ipc: false}});23 24-test('Sets empty result.ipc if ipc is false', async t => {25- const {ipc} = await execa('empty.js');26- t.deepEqual(ipc, []);24+test('Sets empty result.ipcOutput if ipc is false', async t => {25+ const {ipcOutput} = await execa('empty.js');26+ t.deepEqual(ipcOutput, []);27 });28 29-test('Sets empty result.ipc, sync', t => {30- const {ipc} = execaSync('empty.js');31- t.deepEqual(ipc, []);29+test('Sets empty result.ipcOutput, sync', t => {30+ const {ipcOutput} = execaSync('empty.js');31+ t.deepEqual(ipcOutput, []);32 });33 34 const testErrorIpc = async (t, options) => {35- const {ipc} = await t.throwsAsync(execa('ipc-send-fail.js', {...options, ipc: true}));36- t.deepEqual(ipc, [foobarString]);35+ const {ipcOutput} = await t.throwsAsync(execa('ipc-send-fail.js', {...options, ipc: true}));36+ t.deepEqual(ipcOutput, [foobarString]);37 };38 39-test('Sets error.ipc', testErrorIpc, {});40-test('Sets error.ipc, fd-specific buffer', testErrorIpc, {buffer: {stdout: false}});39+test('Sets error.ipcOutput', testErrorIpc, {});40+test('Sets error.ipcOutput, fd-specific buffer', testErrorIpc, {buffer: {stdout: false}});41 42 const testErrorNoBuffer = async (t, options) => {43- const {ipc} = await t.throwsAsync(execa('ipc-send-fail.js', {...options, ipc: true}));44- t.deepEqual(ipc, []);43+ const {ipcOutput} = await t.throwsAsync(execa('ipc-send-fail.js', {...options, ipc: true}));44+ t.deepEqual(ipcOutput, []);45 };46 47-test('Sets empty error.ipc if buffer is false', testErrorNoBuffer, {buffer: false});48-test('Sets empty error.ipc if buffer is false, fd-specific buffer', testErrorNoBuffer, {buffer: {ipc: false}});47+test('Sets empty error.ipcOutput if buffer is false', testErrorNoBuffer, {buffer: false});48+test('Sets empty error.ipcOutput if buffer is false, fd-specific buffer', testErrorNoBuffer, {buffer: {ipc: false}});49 50-test('Sets empty error.ipc if ipc is false', async t => {51- const {ipc} = await t.throwsAsync(execa('fail.js'));52- t.deepEqual(ipc, []);50+test('Sets empty error.ipcOutput if ipc is false', async t => {51+ const {ipcOutput} = await t.throwsAsync(execa('fail.js'));52+ t.deepEqual(ipcOutput, []);53 });54 55-test('Sets empty error.ipc, sync', t => {56- const {ipc} = t.throws(() => execaSync('fail.js'));57- t.deepEqual(ipc, []);55+test('Sets empty error.ipcOutput, sync', t => {56+ const {ipcOutput} = t.throws(() => execaSync('fail.js'));57+ t.deepEqual(ipcOutput, []);58 });modified:test/ipc/get-each.js+16 added-16 removed
11 unmodified lines12 for await (const message of subprocess.getEachMessage()) {13 t.is(message, foobarArray[count++]);14 }15 16- const {ipc} = await subprocess;17- t.deepEqual(ipc, foobarArray);16+ const {ipcOutput} = await subprocess;17+ t.deepEqual(ipcOutput, foobarArray);18 });19 20 test('Can iterate over IPC messages in subprocess', async t => {21 const subprocess = execa('ipc-iterate.js', {ipc: true});1 unmodified line23 await subprocess.sendMessage('.');24 await subprocess.sendMessage('.');25 await subprocess.sendMessage(foobarString);26 27- const {ipc} = await subprocess;28- t.deepEqual(ipc, ['.', '.']);27+ const {ipcOutput} = await subprocess;28+ t.deepEqual(ipcOutput, ['.', '.']);29 });30 31 test('Can iterate multiple times over IPC messages in subprocess', async t => {32 const subprocess = execa('ipc-iterate-twice.js', {ipc: true});6 unmodified lines39 t.is(await subprocess.getOneMessage(), '.');40 await subprocess.sendMessage(foobarString);41 t.is(await subprocess.getOneMessage(), foobarString);42 43- const {ipc} = await subprocess;44- t.deepEqual(ipc, ['.', foobarString, '.', foobarString]);43+ const {ipcOutput} = await subprocess;44+ t.deepEqual(ipcOutput, ['.', foobarString, '.', foobarString]);45 });46 47 test('subprocess.getEachMessage() can be called twice at the same time', async t => {48 const subprocess = execa('ipc-send-twice.js', {ipc: true});1 unmodified line50 await Promise.all([iterateAllMessages(subprocess), iterateAllMessages(subprocess)]),51 [foobarArray, foobarArray],52 );53 54- const {ipc} = await subprocess;55- t.deepEqual(ipc, foobarArray);54+ const {ipcOutput} = await subprocess;55+ t.deepEqual(ipcOutput, foobarArray);56 });57 58 const HIGH_CONCURRENCY_COUNT = 100;59 1 unmodified line61 const subprocess = execa('ipc-iterate.js', {ipc: true});62 await Promise.all(Array.from({length: HIGH_CONCURRENCY_COUNT}, (_, index) => subprocess.sendMessage(index)));63 await subprocess.sendMessage(foobarString);64 65- const {ipc} = await subprocess;66- t.deepEqual(ipc, Array.from({length: HIGH_CONCURRENCY_COUNT}, (_, index) => index));65+ const {ipcOutput} = await subprocess;66+ t.deepEqual(ipcOutput, Array.from({length: HIGH_CONCURRENCY_COUNT}, (_, index) => index));67 });68 69 test('Disconnecting in the current process stops exports.getEachMessage()', async t => {70 const subprocess = execa('ipc-iterate-print.js', {ipc: true});10 unmodified lines81 for await (const message of subprocess.getEachMessage()) {82 t.is(message, foobarString);83 }84 85- const {ipc} = await subprocess;86- t.deepEqual(ipc, [foobarString]);85+ const {ipcOutput} = await subprocess;86+ t.deepEqual(ipcOutput, [foobarString]);87 });88 89 test('Exiting the subprocess stops subprocess.getEachMessage()', async t => {90 const subprocess = execa('ipc-send.js', {ipc: true});91 for await (const message of subprocess.getEachMessage()) {92 t.is(message, foobarString);93 }94 95- const {ipc} = await subprocess;96- t.deepEqual(ipc, [foobarString]);95+ const {ipcOutput} = await subprocess;96+ t.deepEqual(ipcOutput, [foobarString]);97 });98 99 const loopAndBreak = async (t, subprocess) => {100 // eslint-disable-next-line no-unreachable-loop4 unmodified lines105 };106 107 test('Breaking from subprocess.getEachMessage() awaits the subprocess', async t => {108 const subprocess = execa('ipc-send-fail.js', {ipc: true});109- const {exitCode, ipc} = await t.throwsAsync(loopAndBreak(t, subprocess));109+ const {exitCode, ipcOutput} = await t.throwsAsync(loopAndBreak(t, subprocess));110 t.is(exitCode, 1);111- t.deepEqual(ipc, [foobarString]);111+ t.deepEqual(ipcOutput, [foobarString]);112 });113 114 const testCleanupListeners = async (t, buffer) => {115 const subprocess = execa('ipc-send.js', {ipc: true, buffer});16 unmodified linesmodified:test/ipc/get-one.js+6 added-6 removed
45 unmodified lines46 const [chunk] = await once(subprocess.stdout, 'data');47 t.is(chunk.toString(), '.');48 t.is(await Promise.race([setTimeout(1e3), subprocess.getOneMessage()]), undefined);49 await subprocess.sendMessage('.');50- const {ipc} = await subprocess;51- t.deepEqual(ipc, [foobarString]);50+ const {ipcOutput} = await subprocess;51+ t.deepEqual(ipcOutput, [foobarString]);52 });53 54 const HIGH_CONCURRENCY_COUNT = 100;55 9 unmodified lines65 66 test.serial('Can retrieve initial IPC messages under heavy load, buffer true', async t => {67 await Promise.all(68 Array.from({length: HIGH_CONCURRENCY_COUNT}, async (_, index) => {69- const {ipc} = await execa('ipc-send-argv.js', [`${index}`], {ipc: true});70- t.deepEqual(ipc, [`${index}`]);69+ const {ipcOutput} = await execa('ipc-send-argv.js', [`${index}`], {ipc: true});70+ t.deepEqual(ipcOutput, [`${index}`]);71 }),72 );73 });74 32 unmodified lines107 108 test('Cleans up subprocess.getOneMessage() listeners, buffer false', testCleanupListeners, false);109 test('Cleans up subprocess.getOneMessage() listeners, buffer true', testCleanupListeners, true);110 111-test('"error" event interrupts result.ipc', async t => {111+test('"error" event interrupts result.ipcOutput', async t => {112 const subprocess = execa('ipc-echo-twice.js', {ipcInput: foobarString});113 t.is(await subprocess.getOneMessage(), foobarString);114 115 const cause = new Error(foobarString);116 subprocess.emit('error', cause);117 const error = await t.throwsAsync(subprocess);118 t.is(error.cause, cause);119- t.deepEqual(error.ipc, [foobarString]);119+ t.deepEqual(error.ipcOutput, [foobarString]);120 });121 122 const testParentDisconnect = async (t, buffer) => {123 const subprocess = execa('ipc-echo-twice.js', {ipc: true, buffer});70 unmodified linesmodified:test/ipc/ipc-input.js+2 added-2 removed
4 unmodified lines5 6 setFixtureDirectory();7 8 const testSuccess = async (t, options) => {9- const {ipc} = await execa('ipc-echo.js', {ipcInput: foobarString, ...options});10- t.deepEqual(ipc, [foobarString]);9+ const {ipcOutput} = await execa('ipc-echo.js', {ipcInput: foobarString, ...options});10+ t.deepEqual(ipcOutput, [foobarString]);11 };12 13 test('Sends a message with the "ipcInput" option, ipc undefined', testSuccess, {});14 test('Sends a message with the "ipcInput" option, ipc true', testSuccess, {ipc: true});32 unmodified linesmodified:test/ipc/send.js+2 added-2 removed
37 unmodified lines38 test('Handles backpressure', async t => {39 const subprocess = execa('ipc-iterate.js', {ipc: true});40 await subprocess.sendMessage(BIG_PAYLOAD_SIZE);41 t.true(subprocess.send(foobarString));42- const {ipc} = await subprocess;43- t.deepEqual(ipc, [BIG_PAYLOAD_SIZE]);42+ const {ipcOutput} = await subprocess;43+ t.deepEqual(ipcOutput, [BIG_PAYLOAD_SIZE]);44 });45 46 test('Disconnects IPC on exports.sendMessage() error', async t => {47 const subprocess = execa('ipc-echo-twice.js', {ipc: true});37 unmodified linesmodified:test/return/message.js+11 added-11 removed
93 unmodified lines94 const {originalMessage} = await t.throwsAsync(execa('noop.js', {uid: true}));95 t.is(originalMessage, 'The "options.uid" property must be int32. Received type boolean (true)');96 });97 98-const testIpcMessage = async (t, doubles, ipcInput, returnedMessage) => {98+const testIpcOutput = async (t, doubles, ipcInput, returnedMessage) => {99 const fixtureName = doubles ? 'ipc-echo-twice-fail.js' : 'ipc-echo-fail.js';100- const {exitCode, message, ipc} = await t.throwsAsync(execa(fixtureName, {ipcInput}));100+ const {exitCode, message, ipcOutput} = await t.throwsAsync(execa(fixtureName, {ipcInput}));101 t.is(exitCode, 1);102 t.true(message.endsWith(`\n\n${doubles ? `${returnedMessage}\n${returnedMessage}` : returnedMessage}`));103- t.deepEqual(ipc, doubles ? [ipcInput, ipcInput] : [ipcInput]);103+ t.deepEqual(ipcOutput, doubles ? [ipcInput, ipcInput] : [ipcInput]);104 };105 106-test('error.message contains IPC messages, single string', testIpcMessage, false, foobarString, foobarString);107-test('error.message contains IPC messages, two strings', testIpcMessage, true, foobarString, foobarString);108-test('error.message contains IPC messages, single object', testIpcMessage, false, foobarObject, foobarObjectInspect);109-test('error.message contains IPC messages, two objects', testIpcMessage, true, foobarObject, foobarObjectInspect);110-test('error.message contains IPC messages, multiline string', testIpcMessage, false, `${foobarString}\n${foobarString}`, `${foobarString}\n${foobarString}`);111-test('error.message contains IPC messages, control characters', testIpcMessage, false, '\0', '\\u0000');106+test('error.message contains IPC messages, single string', testIpcOutput, false, foobarString, foobarString);107+test('error.message contains IPC messages, two strings', testIpcOutput, true, foobarString, foobarString);108+test('error.message contains IPC messages, single object', testIpcOutput, false, foobarObject, foobarObjectInspect);109+test('error.message contains IPC messages, two objects', testIpcOutput, true, foobarObject, foobarObjectInspect);110+test('error.message contains IPC messages, multiline string', testIpcOutput, false, `${foobarString}\n${foobarString}`, `${foobarString}\n${foobarString}`);111+test('error.message contains IPC messages, control characters', testIpcOutput, false, '\0', '\\u0000');112 113 test('error.message does not contain IPC messages, buffer false', async t => {114- const {exitCode, message, ipc} = await t.throwsAsync(execa('ipc-echo-fail.js', {ipcInput: foobarString, buffer: false}));114+ const {exitCode, message, ipcOutput} = await t.throwsAsync(execa('ipc-echo-fail.js', {ipcInput: foobarString, buffer: false}));115 t.is(exitCode, 1);116 t.true(message.endsWith('ipc-echo-fail.js'));117- t.deepEqual(ipc, []);117+ t.deepEqual(ipcOutput, []);118 });modified:test/return/output.js+2 added-2 removed
120 unmodified lines121 122 test('ipc on subprocess spawning errors', async t => {123 const error = await t.throwsAsync(getEarlyErrorSubprocess({ipc: true}));124 t.like(error, expectedEarlyError);125- t.deepEqual(error.ipc, []);125+ t.deepEqual(error.ipcOutput, []);126 });127 128 const testEarlyErrorNoIpc = async (t, options) => {129 const error = await t.throwsAsync(getEarlyErrorSubprocess(options));130 t.like(error, expectedEarlyError);131- t.deepEqual(error.ipc, []);131+ t.deepEqual(error.ipcOutput, []);132 };133 134 test('ipc on subprocess spawning errors, ipc false', testEarlyErrorNoIpc, {ipc: false});135 test('ipc on subprocess spawning errors, buffer false', testEarlyErrorNoIpc, {buffer: false});modified:test/return/result.js+2 added-2 removed
23 unmodified lines24 'stdout',25 'stderr',26 'all',27 'stdio',28- 'ipc',28+ 'ipcOutput',29 'pipedFrom',30 ]);31 };32 20 unmodified lines53 'stdout',54 'stderr',55 'all',56 'stdio',57- 'ipc',57+ 'ipcOutput',58 'pipedFrom',59 ]);60 };61 82 unmodified linesmodified:test-d/return/result-ipc.ts+25 added-25 removed
9 unmodified lines10 type Options,11 } from '../../index.js';12 13 const ipcResult = await execa('unicorns', {ipc: true});14-expectType<Array<Message<'advanced'>>>(ipcResult.ipc);14+expectType<Array<Message<'advanced'>>>(ipcResult.ipcOutput);15 16 const ipcFdResult = await execa('unicorns', {ipc: true, buffer: {stdout: false}});17-expectType<Array<Message<'advanced'>>>(ipcFdResult.ipc);17+expectType<Array<Message<'advanced'>>>(ipcFdResult.ipcOutput);18 19 const advancedResult = await execa('unicorns', {ipc: true, serialization: 'advanced'});20-expectType<Array<Message<'advanced'>>>(advancedResult.ipc);20+expectType<Array<Message<'advanced'>>>(advancedResult.ipcOutput);21 22 const jsonResult = await execa('unicorns', {ipc: true, serialization: 'json'});23-expectType<Array<Message<'json'>>>(jsonResult.ipc);23+expectType<Array<Message<'json'>>>(jsonResult.ipcOutput);24 25 const inputResult = await execa('unicorns', {ipcInput: ''});26-expectType<Array<Message<'advanced'>>>(inputResult.ipc);26+expectType<Array<Message<'advanced'>>>(inputResult.ipcOutput);27 28 const genericInputResult = await execa('unicorns', {ipcInput: '' as Message});29-expectType<Array<Message<'advanced'>>>(genericInputResult.ipc);29+expectType<Array<Message<'advanced'>>>(genericInputResult.ipcOutput);30 31 const genericResult = await execa('unicorns', {} as Options);32-expectType<Message[] | []>(genericResult.ipc);32+expectType<Message[] | []>(genericResult.ipcOutput);33 34 const genericIpc = await execa('unicorns', {ipc: true as boolean});35-expectType<Array<Message<'advanced'>> | []>(genericIpc.ipc);35+expectType<Array<Message<'advanced'>> | []>(genericIpc.ipcOutput);36 37 const maybeInputResult = await execa('unicorns', {ipcInput: '' as '' | undefined});38-expectType<Array<Message<'advanced'>> | []>(maybeInputResult.ipc);38+expectType<Array<Message<'advanced'>> | []>(maybeInputResult.ipcOutput);39 40 const falseIpcResult = await execa('unicorns', {ipc: false});41-expectType<[]>(falseIpcResult.ipc);41+expectType<[]>(falseIpcResult.ipcOutput);42 43 const noIpcResult = await execa('unicorns');44-expectType<[]>(noIpcResult.ipc);44+expectType<[]>(noIpcResult.ipcOutput);45 46 const emptyIpcResult = await execa('unicorns', {});47-expectType<[]>(emptyIpcResult.ipc);47+expectType<[]>(emptyIpcResult.ipcOutput);48 49 const undefinedInputResult = await execa('unicorns', {ipcInput: undefined});50-expectType<[]>(undefinedInputResult.ipc);50+expectType<[]>(undefinedInputResult.ipcOutput);51 52 const inputNoIpcResult = await execa('unicorns', {ipc: false, ipcInput: ''});53-expectType<[]>(inputNoIpcResult.ipc);53+expectType<[]>(inputNoIpcResult.ipcOutput);54 55 const noBufferResult = await execa('unicorns', {ipc: true, buffer: false});56-expectType<[]>(noBufferResult.ipc);56+expectType<[]>(noBufferResult.ipcOutput);57 58 const noBufferFdResult = await execa('unicorns', {ipc: true, buffer: {ipc: false}});59-expectType<[]>(noBufferFdResult.ipc);59+expectType<[]>(noBufferFdResult.ipcOutput);60 61 const syncResult = execaSync('unicorns');62-expectType<[]>(syncResult.ipc);62+expectType<[]>(syncResult.ipcOutput);63 64-expectType<Message[] | []>({} as Result['ipc']);65-expectAssignable<Message[]>({} as Result['ipc']);66-expectType<[]>({} as unknown as SyncResult['ipc']);64+expectType<Message[] | []>({} as Result['ipcOutput']);65+expectAssignable<Message[]>({} as Result['ipcOutput']);66+expectType<[]>({} as unknown as SyncResult['ipcOutput']);67 68 const ipcError = new Error('.') as ExecaError<{ipc: true}>;69-expectType<Array<Message<'advanced'>>>(ipcError.ipc);69+expectType<Array<Message<'advanced'>>>(ipcError.ipcOutput);70 71 const ipcFalseError = new Error('.') as ExecaError<{ipc: false}>;72-expectType<[]>(ipcFalseError.ipc);72+expectType<[]>(ipcFalseError.ipcOutput);73 74 const asyncError = new Error('.') as ExecaError;75-expectType<Message[] | []>(asyncError.ipc);76-expectAssignable<Message[]>(asyncError.ipc);75+expectType<Message[] | []>(asyncError.ipcOutput);76+expectAssignable<Message[]>(asyncError.ipcOutput);77 78 const syncError = new Error('.') as ExecaSyncError;79-expectType<[]>(syncError.ipc);79+expectType<[]>(syncError.ipcOutput);modified:types/methods/main-async.d.ts+3 added-3 removed
224 unmodified lines225 ```226 // main.js227 import {execaNode} from 'execa';228 229-const {ipc} = await execaNode`build.js`;230-console.log(ipc[0]); // {kind: 'start', timestamp: date}231-console.log(ipc[1]); // {kind: 'stop', timestamp: date}229+const {ipcOutput} = await execaNode`build.js`;230+console.log(ipcOutput[0]); // {kind: 'start', timestamp: date}231+console.log(ipcOutput[1]); // {kind: 'stop', timestamp: date}232 ```233 234 ```235 // build.js74 unmodified linesmodified:types/return/result-ipc.d.ts+2 added-2 removed
1 import type {FdSpecificOption} from '../arguments/specific.js';2 import type {CommonOptions, Options, StricterOptions} from '../arguments/options.js';3 import type {Message, HasIpc} from '../ipc.js';4 5-// `result.ipc`5+// `result.ipcOutput`6 // This is empty unless the `ipc` option is `true`.7 // Also, this is empty if the `buffer` option is `false`.8-export type ResultIpc<8+export type ResultIpcOutput<9 IsSync extends boolean,10 OptionsType extends CommonOptions,11 > = IsSync extends true12 ? []15 unmodified linesmodified:types/return/result.d.ts+2 added-2 removed
3 unmodified lines4 import type {ErrorProperties} from './final-error.js';5 import type {ResultAll} from './result-all.js';6 import type {ResultStdioArray} from './result-stdio.js';7 import type {ResultStdioNotAll} from './result-stdout.js';8-import type {ResultIpc} from './result-ipc.js';8+import type {ResultIpcOutput} from './result-ipc.js';9 10 export declare abstract class CommonResult<11 IsSync extends boolean,12 OptionsType extends CommonOptions,40 unmodified lines53 All the messages sent by the subprocess to the current process.54 55 This is empty unless the `ipc` option is `true`. Also, this is empty if the `buffer` option is `false`.56 */57- ipc: ResultIpc<IsSync, OptionsType>;57+ ipcOutput: ResultIpcOutput<IsSync, OptionsType>;58 59 /**60 Results of the other subprocesses that were piped into this subprocess.61 132 unmodified linesmodified:readme.md+3 added-3 removed
307 unmodified lines308 ```js309 // main.js310 import {execaNode} from 'execa';311 312-const {ipc} = await execaNode`build.js`;313-console.log(ipc[0]); // {kind: 'start', timestamp: date}314-console.log(ipc[1]); // {kind: 'stop', timestamp: date}312+const {ipcOutput} = await execaNode`build.js`;313+console.log(ipcOutput[0]); // {kind: 'start', timestamp: date}314+console.log(ipcOutput[1]); // {kind: 'stop', timestamp: date}315 ```316 317 ```js318 // build.js73 unmodified lines