Skip to content
Myr

Update dev dependencies (#1257)

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

authored by Sindre Sorhus · committed by GitHub · parent 84fa0ec · Browse files · 35 files+106 added−129 removed
This commit

State

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

Diff stats

35 files+106 added−129 removed

  • tests:+63 added−92 removed
  • other:+43 added−37 removed

35 files+106 added−129 removed

modified:lib/arguments/command-file.js+4 added-4 removed
modified:lib/arguments/encoding-option.js+1 added-1 removed
15 unmodified lines
16};1718const TEXT_ENCODINGS = new Set(['utf8', 'utf16le']);19export const BINARY_ENCODINGS = new Set(['buffer', 'hex', 'base64', 'base64url', 'latin1', 'ascii']);20const ENCODINGS = new Set([...TEXT_ENCODINGS, ...BINARY_ENCODINGS]);20const ENCODINGS = TEXT_ENCODINGS.union(BINARY_ENCODINGS);2122const getCorrectEncoding = encoding => {23 if (encoding === null) {24 return 'buffer';
26 unmodified lines
modified:lib/ipc/graceful.js+3 added-3 removed
27 unmodified lines
28 return cancelController.signal;29};3031const startIpc = async ({anyProcess, channel, isSubprocess, ipc}) => {32 if (cancelListening) {32 if (isCancelListening) {33 return;34 }3536 cancelListening = true;36 isCancelListening = true;3738 if (!ipc) {39 throwOnMissingParent();40 return;
7 unmodified lines
48 getIpcEmitter(anyProcess, channel, isSubprocess);49 await scheduler.yield();50};5152let cancelListening = false;52let isCancelListening = false;5354// Reception of IPC message to perform a graceful termination55export const handleAbort = wrappedMessage => {56 if (wrappedMessage?.type !== GRACEFUL_CANCEL_TYPE) {
16 unmodified lines
modified:lib/ipc/methods.js+3 added-3 removed
11 unmodified lines
12// Get promise-based IPC in the subprocess13export const getIpcExport = () => {14 const anyProcess = process;15 const isSubprocess = true;16 const ipc = process.channel !== undefined;16 const isIpc = process.channel !== undefined;1718 return {19 ...getIpcMethods(anyProcess, isSubprocess, ipc),19 ...getIpcMethods(anyProcess, isSubprocess, isIpc),20 getCancelSignal: getCancelSignal.bind(undefined, {21 anyProcess,22 channel: anyProcess.channel,23 isSubprocess,24 ipc,24 ipc: isIpc,25 }),26 };27};28
22 unmodified lines
modified:lib/methods/template.js+4 added-4 removed
57 unmodified lines
58 }5960 const nextTokens = [];61 let templateStart = 0;62 const leadingWhitespaces = DELIMITERS.has(rawTemplate[0]);62 const isLeadingWhitespaces = DELIMITERS.has(rawTemplate[0]);6364 for (65 let templateIndex = 0, rawIndex = 0;66 templateIndex < template.length;
19 unmodified lines
86 }87 }88 }8990 const trailingWhitespaces = templateStart === template.length;91 if (!trailingWhitespaces) {90 const isTrailingWhitespaces = templateStart === template.length;91 if (!isTrailingWhitespaces) {92 nextTokens.push(template.slice(templateStart));93 }9495 return {nextTokens, leadingWhitespaces, trailingWhitespaces};95 return {nextTokens, leadingWhitespaces: isLeadingWhitespaces, trailingWhitespaces: isTrailingWhitespaces};96};9798const DELIMITERS = new Set([' ', '\t', '\r', '\n']);99
54 unmodified lines
modified:lib/resolve/exit-sync.js+2 added-2 removed
modified:lib/transform/split.js+11 added-9 removed
30 unmodified lines
31 let {previousChunks} = state;32 let start = -1;3334 for (let end = 0; end < chunk.length; end += 1) {35 if (chunk[end] === '\n') {36 const newlineLength = getNewlineLength(chunk, end, preserveNewlines, state);37 let line = chunk.slice(start + 1, end + 1 - newlineLength);35 if (chunk[end] !== '\n') {36 continue;37 }3839 if (previousChunks.length > 0) {40 line = concatString(previousChunks, line);41 previousChunks = '';42 }39 const newlineLength = getNewlineLength(chunk, end, preserveNewlines, state);40 let line = chunk.slice(start + 1, end + 1 - newlineLength);4144 yield line;45 start = end;42 if (previousChunks.length > 0) {43 line = concatString(previousChunks, line);44 previousChunks = '';45 }4647 yield line;48 start = end;49 }5051 if (start !== chunk.length - 1) {52 previousChunks = concatString(previousChunks, chunk.slice(start + 1));
60 unmodified lines
modified:lib/verbose/output.js+2 added-2 removed
9 unmodified lines
10// This only leaves with `pipe` and `overlapped`.11export const shouldLogOutput = ({stdioItems, encoding, verboseInfo, fdNumber}) => fdNumber !== 'all'12 && isFullVerbose(verboseInfo, fdNumber)13 && !BINARY_ENCODINGS.has(encoding)14 && fdUsesVerbose(fdNumber)14 && isFdVerbose(fdNumber)15 && (stdioItems.some(({type, value}) => type === 'native' && PIPED_STDIO_VALUES.has(value))16 || stdioItems.every(({type}) => TRANSFORM_TYPES.has(type)));1718// Printing input streams would be confusing.19// Files and streams can produce big outputs, which we don't want to print.20// We could print `stdio[3+]` but it often is redirected to files and streams, with the same issue.21// So we only print stdout and stderr.22const fdUsesVerbose = fdNumber => fdNumber === 1 || fdNumber === 2;22const isFdVerbose = fdNumber => fdNumber === 1 || fdNumber === 2;2324const PIPED_STDIO_VALUES = new Set(['pipe', 'overlapped']);2526// `verbose: 'full'` printing logic with async methods
34 unmodified lines
modified:test/arguments/escape.js+1 added-1 removed
21 unmodified lines
22test(testResultCommand, '');2324// eslint-disable-next-line max-params25const testEscapedCommand = async (t, commandArguments, expectedUnix, expectedWindows, expectedUnixNoIcu = expectedUnix, expectedWindowsNoIcu = expectedWindows) => {26 // eslint-disable-next-line no-use-extend-native/no-use-extend-native -- `RegExp.isMocked` is a static property added by `escape-no-icu.js`, not a native extension26 // eslint-disable-next-line no-use-extend-native/no-use-extend-native, unicorn/no-nonstandard-builtin-properties -- `RegExp.isMocked` is a static property added by `escape-no-icu.js`, not a native extension27 const expected = RegExp.isMocked28 ? (isWindows ? expectedWindowsNoIcu : expectedUnixNoIcu)29 : (isWindows ? expectedWindows : expectedUnix);30
74 unmodified lines
modified:test/convert/readable.js+1 added-4 removed
324 unmodified lines
325});326327test('.readable() can iterate over lines', async t => {328 const subprocess = execa('noop-fd.js', ['1', simpleFull]);329 const lines = [];330 for await (const line of subprocess.readable({binary: false, preserveNewlines: false})) {331 lines.push(line);332 }329 const lines = await Array.fromAsync(subprocess.readable({binary: false, preserveNewlines: false}));330331 const expectedLines = ['aaa', 'bbb', 'ccc'];332 t.deepEqual(lines, expectedLines);333 await assertSubprocessOutput(t, subprocess, simpleFull);
129 unmodified lines
modified:test/fixtures/ipc-get-send-get.js+2 added-2 removed
1#!/usr/bin/env node2import {argv} from 'node:process';3import {sendMessage, getOneMessage} from '../../index.js';4import {alwaysPass} from '../helpers/ipc.js';4import {isAlwaysTrue} from '../helpers/ipc.js';56const filter = argv[2] === 'true' ? alwaysPass : undefined;6const filter = argv[2] === 'true' ? isAlwaysTrue : undefined;78const message = await getOneMessage({filter});9await Promise.all([10 getOneMessage({filter}),
2 unmodified lines
modified:test/fixtures/ipc-iterate-back-serial.js+2 added-2 removed
1#!/usr/bin/env node2import process from 'node:process';3import {sendMessage, getOneMessage} from '../../index.js';4import {PARALLEL_COUNT} from '../helpers/parallel.js';5import {alwaysPass, getFirst} from '../helpers/ipc.js';5import {isAlwaysTrue, getFirst} from '../helpers/ipc.js';67const filter = process.argv[2] === 'true' ? alwaysPass : undefined;7const filter = process.argv[2] === 'true' ? isAlwaysTrue : undefined;89await sendMessage(await getOneMessage({filter}));1011const promise = sendMessage(1);
13 unmodified lines
modified:test/fixtures/ipc-iterate-back.js+2 added-2 removed
1#!/usr/bin/env node2import process from 'node:process';3import {sendMessage, getOneMessage} from '../../index.js';4import {PARALLEL_COUNT} from '../helpers/parallel.js';5import {alwaysPass, getFirst} from '../helpers/ipc.js';5import {isAlwaysTrue, getFirst} from '../helpers/ipc.js';67const filter = process.argv[2] === 'true' ? alwaysPass : undefined;7const filter = process.argv[2] === 'true' ? isAlwaysTrue : undefined;89await sendMessage(await getOneMessage({filter}));1011const messages = Array.from({length: PARALLEL_COUNT}, (_, index) => index + 1);
9 unmodified lines
modified:test/fixtures/ipc-print-many.js+2 added-2 removed
1#!/usr/bin/env node2import {argv} from 'node:process';3import {getOneMessage} from '../../index.js';4import {alwaysPass} from '../helpers/ipc.js';4import {isAlwaysTrue} from '../helpers/ipc.js';56const count = Number(argv[2]);7const filter = argv[3] === 'true' ? alwaysPass : undefined;7const filter = argv[3] === 'true' ? isAlwaysTrue : undefined;89for (let index = 0; index < count; index += 1) {10 // eslint-disable-next-line no-await-in-loop11 console.log(await getOneMessage({filter}));
1 unmodified line
modified:test/fixtures/ipc-process-error.js+2 added-2 removed
1#!/usr/bin/env node2import process from 'node:process';3import {getOneMessage, sendMessage} from '../../index.js';4import {foobarString} from '../helpers/input.js';5import {alwaysPass} from '../helpers/ipc.js';5import {isAlwaysTrue} from '../helpers/ipc.js';67process.on('error', () => {});8const filter = process.argv[2] === 'true' ? alwaysPass : undefined;8const filter = process.argv[2] === 'true' ? isAlwaysTrue : undefined;9const promise = getOneMessage({filter});10process.emit('error', new Error(foobarString));11await sendMessage(await promise);
modified:test/fixtures/ipc-send-pid.js+4 added-4 removed
1#!/usr/bin/env node2import process from 'node:process';3import {execa, sendMessage} from '../../index.js';45const cleanup = process.argv[2] === 'true';6const detached = process.argv[3] === 'true';5const isCleanup = process.argv[2] === 'true';6const isDetached = process.argv[3] === 'true';7const file = process.argv[4] === 'no-killable' ? 'no-killable.js' : 'forever.js';8const options = {9 cleanup,10 detached,9 cleanup: isCleanup,10 detached: isDetached,11 ...(file === 'no-killable.js' && {12 ipc: true,13 killSignal: 'SIGKILL',14 }),
8 unmodified lines
modified:test/helpers/ipc.js+2 added-5 removed
1 unmodified line
2import {foobarString} from './input.js';34// @todo: replace with Array.fromAsync(subprocess.getEachMessage()) after dropping support for Node <22.0.05export const iterateAllMessages = async subprocess => {6 const messages = [];7 for await (const message of subprocess.getEachMessage()) {8 messages.push(message);9 }6 const messages = await Array.fromAsync(subprocess.getEachMessage());78 return messages;9};10
10 unmodified lines
21};2223export const subprocessGetOne = (subprocess, options) => subprocess.getOneMessage(options);2428export const alwaysPass = () => true;25export const isAlwaysTrue = () => true;2627// `process.send()` can fail due to I/O errors.28// However, I/O errors are seldom and hard to trigger predictably.29// So we mock them.
9 unmodified lines
modified:test/ipc/forward.js+3 added-3 removed
1import test from 'ava';2import {execa} from '../../index.js';3import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4import {foobarString, foobarArray} from '../helpers/input.js';5import {iterateAllMessages, alwaysPass} from '../helpers/ipc.js';5import {iterateAllMessages, isAlwaysTrue} from '../helpers/ipc.js';67setFixtureDirectory();89const testParentErrorOne = async (t, filter, buffer) => {
14 unmodified lines
24};2526test('"error" event does not interrupt subprocess.getOneMessage(), buffer false', testParentErrorOne, undefined, false);27test('"error" event does not interrupt subprocess.getOneMessage(), buffer true', testParentErrorOne, undefined, true);28test('"error" event does not interrupt subprocess.getOneMessage(), buffer false, filter', testParentErrorOne, alwaysPass, false);29test('"error" event does not interrupt subprocess.getOneMessage(), buffer true, filter', testParentErrorOne, alwaysPass, true);28test('"error" event does not interrupt subprocess.getOneMessage(), buffer false, filter', testParentErrorOne, isAlwaysTrue, false);29test('"error" event does not interrupt subprocess.getOneMessage(), buffer true, filter', testParentErrorOne, isAlwaysTrue, true);3031const testSubprocessErrorOne = async (t, filter, buffer) => {32 const subprocess = execa('ipc-process-error.js', [`${filter}`], {ipc: true, buffer});33 await subprocess.sendMessage(foobarString);
63 unmodified lines
modified:test/ipc/get-one.js+7 added-7 removed
1import test from 'ava';2import {execa} from '../../index.js';3import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4import {foobarString, foobarArray} from '../helpers/input.js';5import {alwaysPass} from '../helpers/ipc.js';5import {isAlwaysTrue} from '../helpers/ipc.js';6import {PARALLEL_COUNT} from '../helpers/parallel.js';78setFixtureDirectory();9
62 unmodified lines
72};7374test('subprocess.getOneMessage() can be called twice at the same time, buffer false', testTwice, false, undefined);75test('subprocess.getOneMessage() can be called twice at the same time, buffer true', testTwice, true, undefined);76test('subprocess.getOneMessage() can be called twice at the same time, buffer false, filter', testTwice, false, alwaysPass);77test('subprocess.getOneMessage() can be called twice at the same time, buffer true, filter', testTwice, true, alwaysPass);76test('subprocess.getOneMessage() can be called twice at the same time, buffer false, filter', testTwice, false, isAlwaysTrue);77test('subprocess.getOneMessage() can be called twice at the same time, buffer true, filter', testTwice, true, isAlwaysTrue);7879const testCleanupListeners = async (t, buffer, filter) => {80 const subprocess = execa('ipc-send.js', {ipc: true, buffer});81
12 unmodified lines
94};9596test('Cleans up subprocess.getOneMessage() listeners, buffer false', testCleanupListeners, false, undefined);97test('Cleans up subprocess.getOneMessage() listeners, buffer true', testCleanupListeners, true, undefined);98test('Cleans up subprocess.getOneMessage() listeners, buffer false, filter', testCleanupListeners, false, alwaysPass);99test('Cleans up subprocess.getOneMessage() listeners, buffer true, filter', testCleanupListeners, true, alwaysPass);98test('Cleans up subprocess.getOneMessage() listeners, buffer false, filter', testCleanupListeners, false, isAlwaysTrue);99test('Cleans up subprocess.getOneMessage() listeners, buffer true, filter', testCleanupListeners, true, isAlwaysTrue);100101const testParentDisconnect = async (t, buffer, filter) => {102 const subprocess = execa('ipc-get-send-get.js', [`${filter}`], {ipc: true, buffer});103 await subprocess.sendMessage(foobarString);
22 unmodified lines
126};127128test('Subprocess exit interrupts subprocess.getOneMessage(), buffer false', testSubprocessDisconnect, false, undefined);129test('Subprocess exit interrupts subprocess.getOneMessage(), buffer true', testSubprocessDisconnect, true, undefined);130test('Subprocess exit interrupts subprocess.getOneMessage(), buffer false, filter', testSubprocessDisconnect, false, alwaysPass);131test('Subprocess exit interrupts subprocess.getOneMessage(), buffer true, filter', testSubprocessDisconnect, true, alwaysPass);130test('Subprocess exit interrupts subprocess.getOneMessage(), buffer false, filter', testSubprocessDisconnect, false, isAlwaysTrue);131test('Subprocess exit interrupts subprocess.getOneMessage(), buffer true, filter', testSubprocessDisconnect, true, isAlwaysTrue);
modified:test/ipc/incoming.js+3 added-3 removed
1import test from 'ava';2import {execa} from '../../index.js';3import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4import {foobarString} from '../helpers/input.js';5import {alwaysPass} from '../helpers/ipc.js';5import {isAlwaysTrue} from '../helpers/ipc.js';6import {PARALLEL_COUNT} from '../helpers/parallel.js';78setFixtureDirectory();9
12 unmodified lines
22};2324test('subprocess.getOneMessage() can be called multiple times in a row, buffer false', testSeriesParent, false, undefined);25test('subprocess.getOneMessage() can be called multiple times in a row, buffer true', testSeriesParent, true, undefined);26test('subprocess.getOneMessage() can be called multiple times in a row, buffer false, filter', testSeriesParent, false, alwaysPass);27test('subprocess.getOneMessage() can be called multiple times in a row, buffer true, filter', testSeriesParent, true, alwaysPass);26test('subprocess.getOneMessage() can be called multiple times in a row, buffer false, filter', testSeriesParent, false, isAlwaysTrue);27test('subprocess.getOneMessage() can be called multiple times in a row, buffer true, filter', testSeriesParent, true, isAlwaysTrue);2829const testSeriesSubprocess = async (t, filter) => {30 const subprocess = execa('ipc-print-many.js', [`${PARALLEL_COUNT}`, `${filter}`], {ipc: true});31 const indexes = Array.from({length: PARALLEL_COUNT}, (_, index) => `${index}`);
25 unmodified lines
modified:test/ipc/outgoing.js+5 added-5 removed
1import test from 'ava';2import {execa} from '../../index.js';3import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4import {foobarString} from '../helpers/input.js';5import {alwaysPass, subprocessGetOne, subprocessGetFirst} from '../helpers/ipc.js';5import {isAlwaysTrue, subprocessGetOne, subprocessGetFirst} from '../helpers/ipc.js';6import {PARALLEL_COUNT} from '../helpers/parallel.js';78setFixtureDirectory();9
19 unmodified lines
29};3031test('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer false', testSendHoldParent, subprocessGetOne, false, undefined);32test('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer true', testSendHoldParent, subprocessGetOne, true, undefined);33test('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer false, filter', testSendHoldParent, subprocessGetOne, false, alwaysPass);34test('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer true, filter', testSendHoldParent, subprocessGetOne, true, alwaysPass);33test('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer false, filter', testSendHoldParent, subprocessGetOne, false, isAlwaysTrue);34test('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer true, filter', testSendHoldParent, subprocessGetOne, true, isAlwaysTrue);35test('Multiple parallel subprocess.sendMessage() + subprocess.getEachMessage(), buffer false', testSendHoldParent, subprocessGetFirst, false, undefined);36test('Multiple parallel subprocess.sendMessage() + subprocess.getEachMessage(), buffer true', testSendHoldParent, subprocessGetFirst, true, undefined);3738const testSendHoldSubprocess = async (t, filter, isGetEach) => {
32 unmodified lines
71};7273test('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer false', testSendHoldParentSerial, subprocessGetOne, false, undefined);74test('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer true', testSendHoldParentSerial, subprocessGetOne, true, undefined);75test('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer false, filter', testSendHoldParentSerial, subprocessGetOne, false, alwaysPass);76test('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer true, filter', testSendHoldParentSerial, subprocessGetOne, true, alwaysPass);75test('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer false, filter', testSendHoldParentSerial, subprocessGetOne, false, isAlwaysTrue);76test('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer true, filter', testSendHoldParentSerial, subprocessGetOne, true, isAlwaysTrue);77test('Multiple serial subprocess.sendMessage() + subprocess.getEachMessage(), buffer false', testSendHoldParentSerial, subprocessGetFirst, false, undefined);78test('Multiple serial subprocess.sendMessage() + subprocess.getEachMessage(), buffer true', testSendHoldParentSerial, subprocessGetFirst, true, undefined);7980const testSendHoldSubprocessSerial = async (t, filter, isGetEach) => {
8 unmodified lines
modified:test/methods/main-async.js+1 added
61 unmodified lines
62 t.is(subprocess.signalCode, undefined);63 t.is(subprocess.killed, undefined);64 t.is(subprocess.spawnargs, undefined);65 t.is(subprocess.spawnfile, undefined);66 // eslint-disable-next-line unicorn/no-nonstandard-builtin-properties -- `Symbol.dispose` is a standard well-known symbol, not yet recognized by this rule.67 t.is(subprocess[Symbol.dispose], undefined);68 await subprocess;69});70
10 unmodified lines
modified:test/pipe/methods.js+12 added-30 removed
34 unmodified lines
35 await Promise.allSettled(subprocesses);36};3738const getPipeMessages = async piped => {39 const messages = [];40 for await (const message of piped.getEachMessage()) {41 messages.push(message);42 }39 const messages = await Array.fromAsync(piped.getEachMessage());4041 return messages;42};4344test('The .pipe() return value can be iterated', async t => {48 const lines = [];49 for await (const line of pipeSimple()) {50 lines.push(line);51 }45 const lines = await Array.fromAsync(pipeSimple());4647 t.deepEqual(lines, noNewlinesChunks);48});4950test('The .pipe() return value has an .iterable() method', async t => {57 const lines = [];58 for await (const line of pipeSimple().iterable()) {59 lines.push(line);60 }51 const lines = await Array.fromAsync(pipeSimple().iterable());5253 t.deepEqual(lines, noNewlinesChunks);54});55
16 unmodified lines
72 t.is(secondOutput, simpleFull);73});7475test('The .pipe() return value .readable() keeps conversion options', async t => {85 const chunks = [];86 for await (const chunk of pipeSimple().readable({binary: false, preserveNewlines: false})) {87 chunks.push(chunk);88 }76 const chunks = await Array.fromAsync(pipeSimple().readable({binary: false, preserveNewlines: false}));7778 t.deepEqual(chunks, noNewlinesChunks);79 t.is(chunks.join(''), noNewlinesFull);80});
45 unmodified lines
126});127128test('The .pipe() return value .iterable() can read destination stderr', async t => {129 const piped = pipeDistinctBoth();142 const lines = [];143 for await (const line of piped.iterable({from: 'stderr'})) {144 lines.push(line);145 }130 const lines = await Array.fromAsync(piped.iterable({from: 'stderr'}));131132 t.deepEqual(lines, ['aaa', 'bbb', 'ccc:stderr']);133 await piped;134});
80 unmodified lines
215 abortController.abort();216 await Promise.all(readerPromises.map(async readerPromise => assertSettles(t, readerPromise)));217});218234const assertCanceledPipeMessageReader = async (t, getReader, abortBeforePipe = false) => {219const assertCanceledPipeMessageReader = async (t, getReader, shouldAbortBeforePipe = false) => {220 const abortController = new AbortController();236 if (abortBeforePipe) {221 if (shouldAbortBeforePipe) {222 abortController.abort();223 }224225 const source = execa('noop-repeat.js');
4 unmodified lines
230231 const piped = source.pipe(destination, {unpipeSignal: abortController.signal});232 const readerPromise = t.throwsAsync(getReader(piped), {message: /Pipe canceled/});233249 if (!abortBeforePipe) {234 if (!shouldAbortBeforePipe) {235 abortController.abort();236 }237238 await assertSettles(t, readerPromise);
98 unmodified lines
337 await piped;338});339340test('A chained .pipe() return value can be iterated', async t => {356 const lines = [];357 for await (const line of execa('noop-fd.js', ['1', simpleFull]).pipe('stdin.js').pipe('stdin.js')) {358 lines.push(line);359 }341 const lines = await Array.fromAsync(execa('noop-fd.js', ['1', simpleFull]).pipe('stdin.js').pipe('stdin.js'));342343 t.deepEqual(lines, noNewlinesChunks);344});345
28 unmodified lines
374375 await t.throwsAsync(text(piped.all), {message: /Command failed with exit code 2/});376});377396const assertCanceledPipeReader = async (t, getReader, abortBeforePipe = false) => {378const assertCanceledPipeReader = async (t, getReader, shouldAbortBeforePipe = false) => {379 const abortController = new AbortController();398 if (abortBeforePipe) {380 if (shouldAbortBeforePipe) {381 abortController.abort();382 }383384 const source = execa('stdin.js');
4 unmodified lines
389390 const piped = source.pipe(destination, {unpipeSignal: abortController.signal});391 const readerPromise = t.throwsAsync(getReader(piped), {message: /Pipe canceled/});392411 if (!abortBeforePipe) {393 if (!shouldAbortBeforePipe) {394 abortController.abort();395 }396397 await assertSettles(t, readerPromise, 200);
32 unmodified lines
modified:test/return/early-error.js+2 added-8 removed
125 unmodified lines
126test('child_process.spawn() early errors can use .getEachMessage()', testEarlyErrorIpc, subprocess => subprocess.getEachMessage());127128test('child_process.spawn() early errors can use .iterable()', async t => {129 const subprocess = getEarlyErrorSubprocess();130 const lines = [];131 for await (const line of subprocess.iterable()) {132 lines.push(line);133 }130 const lines = await Array.fromAsync(subprocess.iterable());131132 t.deepEqual(lines, []);133 await t.throwsAsync(subprocess);134});135136test('child_process.spawn() early errors can use Symbol.asyncIterator', async t => {137 const subprocess = getEarlyErrorSubprocess();141 const lines = [];142 for await (const line of subprocess) {143 lines.push(line);144 }138 const lines = await Array.fromAsync(subprocess);139140 t.deepEqual(lines, []);141 await t.throwsAsync(subprocess);142});
16 unmodified lines
modified:test/stdio/node-stream-custom.js+3 added-3 removed
61 unmodified lines
62test('stderr cannot be [Writable, "pipe"] without a file descriptor, sync', testLazyFileWritableSync, 2);63test('stdio[*] cannot be [Writable, "pipe"] without a file descriptor, sync', testLazyFileWritableSync, 3);6465test('Waits for custom streams destroy on subprocess errors', async t => {66 let waitedForDestroy = false;66 let isWaitedForDestroy = false;67 const stream = new Writable({68 destroy: callbackify(async error => {69 await setImmediate();70 waitedForDestroy = true;70 isWaitedForDestroy = true;71 return error;72 }),73 });74 const {timedOut} = await t.throwsAsync(execa('forever.js', {stdout: [stream, 'pipe'], timeout: 1}));75 t.true(timedOut);76 t.true(waitedForDestroy);76 t.true(isWaitedForDestroy);77});7879test('Handles custom streams destroy errors on subprocess success', async t => {80 const cause = new Error('test');
80 unmodified lines
modified:test/stdio/web-stream.js+3 added-3 removed
42 unmodified lines
43test('stderr cannot be a WritableStream - sync', testWebStreamSync, WritableStream, 2, 'stderr');44test('stdio[*] cannot be a WritableStream - sync', testWebStreamSync, WritableStream, 3, 'stdio[3]');4546const testLongWritableStream = async (t, fdNumber) => {47 let result = false;47 let isResult = false;48 const writableStream = new WritableStream({49 async close() {50 await setImmediate();51 result = true;51 isResult = true;52 },53 });54 await execa('empty.js', getStdio(fdNumber, writableStream));55 t.true(result);55 t.true(isResult);56};5758test('stdout waits for WritableStream completion', testLongWritableStream, 1);59test('stderr waits for WritableStream completion', testLongWritableStream, 2);
39 unmodified lines
modified:test/transform/encoding-multibyte.js+1 added-1 removed
20 unmodified lines
21 });22 if (objectMode) {23 t.deepEqual(stdout, foobarArray);24 } else {25 // eslint-disable-next-line n/prefer-global/buffer, unicorn/prefer-uint8array-base64 -- `Uint8Array#toBase64()` is not available on the minimum supported Node.js version25 // eslint-disable-next-line n/prefer-global/buffer -- `Uint8Array#toBase64()` is not available on the minimum supported Node.js version26 t.is(stdout, Buffer.from(foobarArray.join('')).toString('base64'));27 }28};29
51 unmodified lines
modified:test/verbose/output-progressive.js+5 added-5 removed
25 unmodified lines
2627test.serial('Prints stdout progressively, interleaved', async t => {28 const subprocess = nestedInstance('noop-repeat.js', ['1', `${foobarString}\n`], {parentFixture: 'nested-double.js', verbose: 'full'});2930 let firstSubprocessPrinted = false;31 let secondSubprocessPrinted = false;30 let isFirstSubprocessPrinted = false;31 let isSecondSubprocessPrinted = false;32 for await (const chunk of on(subprocess.stderr, 'data')) {33 const outputLine = getOutputLine(chunk.toString().trim());34 if (outputLine === undefined) {35 continue;36 }3738 if (outputLine.includes(foobarString)) {39 t.is(outputLine, `${testTimestamp} [0] ${foobarString}`);40 firstSubprocessPrinted ||= true;40 isFirstSubprocessPrinted ||= true;41 } else {42 t.is(outputLine, `${testTimestamp} [1] ${foobarString.toUpperCase()}`);43 secondSubprocessPrinted ||= true;43 isSecondSubprocessPrinted ||= true;44 }4546 if (firstSubprocessPrinted && secondSubprocessPrinted) {46 if (isFirstSubprocessPrinted && isSecondSubprocessPrinted) {47 break;48 }49 }50
11 unmodified lines
modified:test-d/return/result-stdio.test-d.ts+3 added-3 removed
121 unmodified lines
122123const outputPipeFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'pipe'}]});124expectType<string>(outputPipeFd3Result.stdio[3]);125126const input = true as boolean;127const booleanInputPipeFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'pipe', input}]});126const isInput = true as boolean;127const booleanInputPipeFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'pipe', input: isInput}]});128expectType<string | undefined>(booleanInputPipeFd3Result.stdio[3]);129130const optionalInputPipe: {readonly value: 'pipe'; readonly input?: boolean} = {value: 'pipe', input};130const optionalInputPipe: {readonly value: 'pipe'; readonly input?: boolean} = {value: 'pipe', input: isInput};131const optionalInputPipeFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', optionalInputPipe]});132expectType<string | undefined>(optionalInputPipeFd3Result.stdio[3]);133134const optionalTrueInputPipe: {readonly value: 'pipe'; readonly input?: true} = {value: 'pipe', input: true};
22 unmodified lines
modified:test-d/stdio/option/generator-boolean-full.test-d.ts+1 added
7 unmodified lines
8 type StdoutStderrSyncOption,9} from '../../../index.js';1011const booleanGeneratorFull = {12 // eslint-disable-next-line unicorn/consistent-boolean-name -- `line` matches the naming convention used by every other generator test file, mistyped on purpose to test the type error.13 * transform(line: boolean) {14 yield line;15 },16} as const;
33 unmodified lines
modified:test-d/stdio/option/generator-boolean.test-d.ts+1 added
6 unmodified lines
7 type StdoutStderrOption,8 type StdoutStderrSyncOption,9} from '../../../index.js';1011// eslint-disable-next-line unicorn/consistent-boolean-name -- `line` matches the naming convention used by every other generator test file, mistyped on purpose to test the type error.12const booleanGenerator = function * (line: boolean) {13 yield line;14};15
32 unmodified lines
modified:test-d/stdio/option/input-pipe.test-d.ts+2 added-2 removed
8 unmodified lines
9 type StdoutStderrSyncOption,10} from '../../../index.js';1112const inputPipe = {value: 'pipe', input: true} as const;13const input = true as boolean;14const booleanInputPipe = {value: 'pipe', input} as const;13const isInput = true as boolean;14const booleanInputPipe = {value: 'pipe', input: isInput} as const;15const transform = function * (line: string) {16 yield line;17};18
46 unmodified lines
modified:test-d/subprocess/stdio.test-d.ts+3 added-3 removed
53 unmodified lines
5455const inputFileSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: {file: './example'}, input: true}]});56expectType<Writable>(inputFileSubprocess.stdio[3]);5758const input = true as boolean;59const booleanInputPipeSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'pipe', input}]});58const isInput = true as boolean;59const booleanInputPipeSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'pipe', input: isInput}]});60expectType<Readable | Writable>(booleanInputPipeSubprocess.stdio[3]);6162const optionalInputPipe: {readonly value: 'pipe'; readonly input?: boolean} = {value: 'pipe', input};62const optionalInputPipe: {readonly value: 'pipe'; readonly input?: boolean} = {value: 'pipe', input: isInput};63const optionalInputPipeSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', optionalInputPipe]});64expectType<Readable | Writable>(optionalInputPipeSubprocess.stdio[3]);6566const optionalTrueInputPipe: {readonly value: 'pipe'; readonly input?: true} = {value: 'pipe', input: true};
10 unmodified lines
modified:test-d/verbose.test-d.ts+2 added
44 unmodified lines
45await execa('unicorns', {verbose: (verboseLine: string) => ''});46execaSync('unicorns', {verbose: (verboseLine: string) => ''});47await execa('unicorns', {verbose: (verboseLine: unknown) => ''});48execaSync('unicorns', {verbose: (verboseLine: unknown) => ''});49// eslint-disable-next-line unicorn/consistent-boolean-name -- `verboseLine` matches the real callback parameter name, mistyped on purpose to test the type error.50expectError(await execa('unicorns', {verbose: (verboseLine: boolean) => ''}));51// eslint-disable-next-line unicorn/consistent-boolean-name -- `verboseLine` matches the real callback parameter name, mistyped on purpose to test the type error.52expectError(execaSync('unicorns', {verbose: (verboseLine: boolean) => ''}));53expectError(await execa('unicorns', {verbose: (verboseLine: never) => ''}));54expectError(execaSync('unicorns', {verbose: (verboseLine: never) => ''}));55
44 unmodified lines
modified:package.json+1 added-1 removed
75 unmodified lines
76 "path-exists": "^5.0.0",77 "tempfile": "^6.0.1",78 "tsd": "^0.33.0",79 "typescript": "^6.0.3",80 "xo": "^3.0.2"80 "xo": "^4.0.0"81 },82 "c8": {83 "reporter": [84 "text",
46 unmodified lines