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
Provenance
- Commit
5944b2d- Tree
18cf912- Author
Sindre Sorhus <sindresorhus@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
84fa0ec
35 files changed+106 added−129 removed
modified:lib/arguments/command-file.js+4 added-4 removed
41 unmodified lines424344454646474849495051525394 unmodified lines1481491501511521531521531541551561573 unmodified lines41 unmodified lines for (const value of [parsed.file, ...parsed.commandArguments]) { assertNoLineBreak(value); }
const doubleEscape = resolvedFile !== undefined && batchFileRegExp.test(resolvedFile); const isDoubleEscape = resolvedFile !== undefined && batchFileRegExp.test(resolvedFile); // POSIX separators must become Windows ones (`foo/bar` -> `foo\bar`), otherwise resolution always fails with ENOENT const escapedFile = escapeMetaChars(path.normalize(parsed.file)); const escapedArguments = parsed.commandArguments.map(argument => escapeArgument(argument, doubleEscape)); const escapedArguments = parsed.commandArguments.map(argument => escapeArgument(argument, isDoubleEscape)); const commandLine = `"${[escapedFile, ...escapedArguments].join(' ')}"`;
// Let `node:child_process` pass the already-escaped command line through untouched parsed.options.windowsVerbatimArguments = true;94 unmodified lines */ const argument = `${rawArgument}` .replaceAll(backslashRunRegExp, (backslashes, offset, string) => { const nextCharacter = string[offset + backslashes.length]; const precedesDoubleQuote = nextCharacter === '"' || nextCharacter === undefined; return precedesDoubleQuote ? backslashes.repeat(2) : backslashes; const isPrecedesDoubleQuote = nextCharacter === '"' || nextCharacter === undefined; return isPrecedesDoubleQuote ? backslashes.repeat(2) : backslashes; }) .replaceAll('"', '\\"');
// Wrap the whole argument in double quotes, then caret-escape the metacharacters, a second time when targeting a cmd-shim3 unmodified linesmodified:lib/arguments/encoding-option.js+1 added-1 removed
15 unmodified lines16 };17 18 const TEXT_ENCODINGS = new Set(['utf8', 'utf16le']);19 export const BINARY_ENCODINGS = new Set(['buffer', 'hex', 'base64', 'base64url', 'latin1', 'ascii']);20-const ENCODINGS = new Set([...TEXT_ENCODINGS, ...BINARY_ENCODINGS]);20+const ENCODINGS = TEXT_ENCODINGS.union(BINARY_ENCODINGS);21 22 const getCorrectEncoding = encoding => {23 if (encoding === null) {24 return 'buffer';26 unmodified linesmodified:lib/ipc/graceful.js+3 added-3 removed
27 unmodified lines28 return cancelController.signal;29 };30 31 const startIpc = async ({anyProcess, channel, isSubprocess, ipc}) => {32- if (cancelListening) {32+ if (isCancelListening) {33 return;34 }35 36- cancelListening = true;36+ isCancelListening = true;37 38 if (!ipc) {39 throwOnMissingParent();40 return;7 unmodified lines48 getIpcEmitter(anyProcess, channel, isSubprocess);49 await scheduler.yield();50 };51 52-let cancelListening = false;52+let isCancelListening = false;53 54 // Reception of IPC message to perform a graceful termination55 export const handleAbort = wrappedMessage => {56 if (wrappedMessage?.type !== GRACEFUL_CANCEL_TYPE) {16 unmodified linesmodified:lib/ipc/methods.js+3 added-3 removed
11 unmodified lines12 // Get promise-based IPC in the subprocess13 export const getIpcExport = () => {14 const anyProcess = process;15 const isSubprocess = true;16- const ipc = process.channel !== undefined;16+ const isIpc = process.channel !== undefined;17 18 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 linesmodified:lib/methods/template.js+4 added-4 removed
57 unmodified lines58 }59 60 const nextTokens = [];61 let templateStart = 0;62- const leadingWhitespaces = DELIMITERS.has(rawTemplate[0]);62+ const isLeadingWhitespaces = DELIMITERS.has(rawTemplate[0]);63 64 for (65 let templateIndex = 0, rawIndex = 0;66 templateIndex < template.length;19 unmodified lines86 }87 }88 }89 90- const trailingWhitespaces = templateStart === template.length;91- if (!trailingWhitespaces) {90+ const isTrailingWhitespaces = templateStart === template.length;91+ if (!isTrailingWhitespaces) {92 nextTokens.push(template.slice(templateStart));93 }94 95- return {nextTokens, leadingWhitespaces, trailingWhitespaces};95+ return {nextTokens, leadingWhitespaces: isLeadingWhitespaces, trailingWhitespaces: isTrailingWhitespaces};96 };97 98 const DELIMITERS = new Set([' ', '\t', '\r', '\n']);99 54 unmodified linesmodified:lib/resolve/exit-sync.js+2 added-2 removed
3 unmodified lines4567889101112131414151617187 unmodified lines3 unmodified lines
// Retrieve exit code, signal name and error information, with synchronous methodsexport const getExitResultSync = ({error, status: exitCode, signal, output}, {maxBuffer}) => { const resultError = getResultError(error, exitCode, signal); const timedOut = resultError?.code === 'ETIMEDOUT'; const isTimedOut = resultError?.code === 'ETIMEDOUT'; const isMaxBuffer = isMaxBufferSync(resultError, output, maxBuffer); return { resultError, exitCode, signal, timedOut, timedOut: isTimedOut, isMaxBuffer, };};
7 unmodified linesmodified:lib/transform/split.js+11 added-9 removed
30 unmodified lines31 let {previousChunks} = state;32 let start = -1;33 34 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+ }38 39- 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);41 44- yield line;45- start = end;42+ if (previousChunks.length > 0) {43+ line = concatString(previousChunks, line);44+ previousChunks = '';45 }46+47+ yield line;48+ start = end;49 }50 51 if (start !== chunk.length - 1) {52 previousChunks = concatString(previousChunks, chunk.slice(start + 1));60 unmodified linesmodified:lib/verbose/output.js+2 added-2 removed
9 unmodified lines10 // This only leaves with `pipe` and `overlapped`.11 export 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)));17 18 // 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.22-const fdUsesVerbose = fdNumber => fdNumber === 1 || fdNumber === 2;22+const isFdVerbose = fdNumber => fdNumber === 1 || fdNumber === 2;23 24 const PIPED_STDIO_VALUES = new Set(['pipe', 'overlapped']);25 26 // `verbose: 'full'` printing logic with async methods34 unmodified linesmodified:test/arguments/escape.js+1 added-1 removed
21 unmodified lines22 test(testResultCommand, '');23 24 // eslint-disable-next-line max-params25 const 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 linesmodified:test/convert/readable.js+1 added-4 removed
324 unmodified lines325 });326 327 test('.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}));330 331 const expectedLines = ['aaa', 'bbb', 'ccc'];332 t.deepEqual(lines, expectedLines);333 await assertSubprocessOutput(t, subprocess, simpleFull);129 unmodified linesmodified:test/fixtures/ipc-get-send-get.js+2 added-2 removed
1 #!/usr/bin/env node2 import {argv} from 'node:process';3 import {sendMessage, getOneMessage} from '../../index.js';4-import {alwaysPass} from '../helpers/ipc.js';4+import {isAlwaysTrue} from '../helpers/ipc.js';5 6-const filter = argv[2] === 'true' ? alwaysPass : undefined;6+const filter = argv[2] === 'true' ? isAlwaysTrue : undefined;7 8 const message = await getOneMessage({filter});9 await Promise.all([10 getOneMessage({filter}),2 unmodified linesmodified:test/fixtures/ipc-iterate-back-serial.js+2 added-2 removed
1 #!/usr/bin/env node2 import process from 'node:process';3 import {sendMessage, getOneMessage} from '../../index.js';4 import {PARALLEL_COUNT} from '../helpers/parallel.js';5-import {alwaysPass, getFirst} from '../helpers/ipc.js';5+import {isAlwaysTrue, getFirst} from '../helpers/ipc.js';6 7-const filter = process.argv[2] === 'true' ? alwaysPass : undefined;7+const filter = process.argv[2] === 'true' ? isAlwaysTrue : undefined;8 9 await sendMessage(await getOneMessage({filter}));10 11 const promise = sendMessage(1);13 unmodified linesmodified:test/fixtures/ipc-iterate-back.js+2 added-2 removed
1 #!/usr/bin/env node2 import process from 'node:process';3 import {sendMessage, getOneMessage} from '../../index.js';4 import {PARALLEL_COUNT} from '../helpers/parallel.js';5-import {alwaysPass, getFirst} from '../helpers/ipc.js';5+import {isAlwaysTrue, getFirst} from '../helpers/ipc.js';6 7-const filter = process.argv[2] === 'true' ? alwaysPass : undefined;7+const filter = process.argv[2] === 'true' ? isAlwaysTrue : undefined;8 9 await sendMessage(await getOneMessage({filter}));10 11 const messages = Array.from({length: PARALLEL_COUNT}, (_, index) => index + 1);9 unmodified linesmodified:test/fixtures/ipc-print-many.js+2 added-2 removed
1 #!/usr/bin/env node2 import {argv} from 'node:process';3 import {getOneMessage} from '../../index.js';4-import {alwaysPass} from '../helpers/ipc.js';4+import {isAlwaysTrue} from '../helpers/ipc.js';5 6 const count = Number(argv[2]);7-const filter = argv[3] === 'true' ? alwaysPass : undefined;7+const filter = argv[3] === 'true' ? isAlwaysTrue : undefined;8 9 for (let index = 0; index < count; index += 1) {10 // eslint-disable-next-line no-await-in-loop11 console.log(await getOneMessage({filter}));1 unmodified linemodified:test/fixtures/ipc-process-error.js+2 added-2 removed
1 #!/usr/bin/env node2 import process from 'node:process';3 import {getOneMessage, sendMessage} from '../../index.js';4 import {foobarString} from '../helpers/input.js';5-import {alwaysPass} from '../helpers/ipc.js';5+import {isAlwaysTrue} from '../helpers/ipc.js';6 7 process.on('error', () => {});8-const filter = process.argv[2] === 'true' ? alwaysPass : undefined;8+const filter = process.argv[2] === 'true' ? isAlwaysTrue : undefined;9 const promise = getOneMessage({filter});10 process.emit('error', new Error(foobarString));11 await sendMessage(await promise);modified:test/fixtures/ipc-send-pid.js+4 added-4 removed
1 #!/usr/bin/env node2 import process from 'node:process';3 import {execa, sendMessage} from '../../index.js';4 5-const cleanup = process.argv[2] === 'true';6-const detached = process.argv[3] === 'true';5+const isCleanup = process.argv[2] === 'true';6+const isDetached = process.argv[3] === 'true';7 const file = process.argv[4] === 'no-killable' ? 'no-killable.js' : 'forever.js';8 const 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 linesmodified:test/helpers/ipc.js+2 added-5 removed
1 unmodified line2 import {foobarString} from './input.js';3 4 // @todo: replace with Array.fromAsync(subprocess.getEachMessage()) after dropping support for Node <22.0.05 export 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());7 8 return messages;9 };10 10 unmodified lines21 };22 23 export const subprocessGetOne = (subprocess, options) => subprocess.getOneMessage(options);24 28-export const alwaysPass = () => true;25+export const isAlwaysTrue = () => true;26 27 // `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 linesmodified:test/ipc/forward.js+3 added-3 removed
1 import test from 'ava';2 import {execa} from '../../index.js';3 import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {foobarString, foobarArray} from '../helpers/input.js';5-import {iterateAllMessages, alwaysPass} from '../helpers/ipc.js';5+import {iterateAllMessages, isAlwaysTrue} from '../helpers/ipc.js';6 7 setFixtureDirectory();8 9 const testParentErrorOne = async (t, filter, buffer) => {14 unmodified lines24 };25 26 test('"error" event does not interrupt subprocess.getOneMessage(), buffer false', testParentErrorOne, undefined, false);27 test('"error" event does not interrupt subprocess.getOneMessage(), buffer true', testParentErrorOne, undefined, true);28-test('"error" event does not interrupt subprocess.getOneMessage(), buffer false, filter', testParentErrorOne, alwaysPass, false);29-test('"error" event does not interrupt subprocess.getOneMessage(), buffer true, filter', testParentErrorOne, alwaysPass, true);28+test('"error" event does not interrupt subprocess.getOneMessage(), buffer false, filter', testParentErrorOne, isAlwaysTrue, false);29+test('"error" event does not interrupt subprocess.getOneMessage(), buffer true, filter', testParentErrorOne, isAlwaysTrue, true);30 31 const testSubprocessErrorOne = async (t, filter, buffer) => {32 const subprocess = execa('ipc-process-error.js', [`${filter}`], {ipc: true, buffer});33 await subprocess.sendMessage(foobarString);63 unmodified linesmodified:test/ipc/get-one.js+7 added-7 removed
1 import test from 'ava';2 import {execa} from '../../index.js';3 import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {foobarString, foobarArray} from '../helpers/input.js';5-import {alwaysPass} from '../helpers/ipc.js';5+import {isAlwaysTrue} from '../helpers/ipc.js';6 import {PARALLEL_COUNT} from '../helpers/parallel.js';7 8 setFixtureDirectory();9 62 unmodified lines72 };73 74 test('subprocess.getOneMessage() can be called twice at the same time, buffer false', testTwice, false, undefined);75 test('subprocess.getOneMessage() can be called twice at the same time, buffer true', testTwice, true, undefined);76-test('subprocess.getOneMessage() can be called twice at the same time, buffer false, filter', testTwice, false, alwaysPass);77-test('subprocess.getOneMessage() can be called twice at the same time, buffer true, filter', testTwice, true, alwaysPass);76+test('subprocess.getOneMessage() can be called twice at the same time, buffer false, filter', testTwice, false, isAlwaysTrue);77+test('subprocess.getOneMessage() can be called twice at the same time, buffer true, filter', testTwice, true, isAlwaysTrue);78 79 const testCleanupListeners = async (t, buffer, filter) => {80 const subprocess = execa('ipc-send.js', {ipc: true, buffer});81 12 unmodified lines94 };95 96 test('Cleans up subprocess.getOneMessage() listeners, buffer false', testCleanupListeners, false, undefined);97 test('Cleans up subprocess.getOneMessage() listeners, buffer true', testCleanupListeners, true, undefined);98-test('Cleans up subprocess.getOneMessage() listeners, buffer false, filter', testCleanupListeners, false, alwaysPass);99-test('Cleans up subprocess.getOneMessage() listeners, buffer true, filter', testCleanupListeners, true, alwaysPass);98+test('Cleans up subprocess.getOneMessage() listeners, buffer false, filter', testCleanupListeners, false, isAlwaysTrue);99+test('Cleans up subprocess.getOneMessage() listeners, buffer true, filter', testCleanupListeners, true, isAlwaysTrue);100 101 const 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 lines126 };127 128 test('Subprocess exit interrupts subprocess.getOneMessage(), buffer false', testSubprocessDisconnect, false, undefined);129 test('Subprocess exit interrupts subprocess.getOneMessage(), buffer true', testSubprocessDisconnect, true, undefined);130-test('Subprocess exit interrupts subprocess.getOneMessage(), buffer false, filter', testSubprocessDisconnect, false, alwaysPass);131-test('Subprocess exit interrupts subprocess.getOneMessage(), buffer true, filter', testSubprocessDisconnect, true, alwaysPass);130+test('Subprocess exit interrupts subprocess.getOneMessage(), buffer false, filter', testSubprocessDisconnect, false, isAlwaysTrue);131+test('Subprocess exit interrupts subprocess.getOneMessage(), buffer true, filter', testSubprocessDisconnect, true, isAlwaysTrue);modified:test/ipc/incoming.js+3 added-3 removed
1 import test from 'ava';2 import {execa} from '../../index.js';3 import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {foobarString} from '../helpers/input.js';5-import {alwaysPass} from '../helpers/ipc.js';5+import {isAlwaysTrue} from '../helpers/ipc.js';6 import {PARALLEL_COUNT} from '../helpers/parallel.js';7 8 setFixtureDirectory();9 12 unmodified lines22 };23 24 test('subprocess.getOneMessage() can be called multiple times in a row, buffer false', testSeriesParent, false, undefined);25 test('subprocess.getOneMessage() can be called multiple times in a row, buffer true', testSeriesParent, true, undefined);26-test('subprocess.getOneMessage() can be called multiple times in a row, buffer false, filter', testSeriesParent, false, alwaysPass);27-test('subprocess.getOneMessage() can be called multiple times in a row, buffer true, filter', testSeriesParent, true, alwaysPass);26+test('subprocess.getOneMessage() can be called multiple times in a row, buffer false, filter', testSeriesParent, false, isAlwaysTrue);27+test('subprocess.getOneMessage() can be called multiple times in a row, buffer true, filter', testSeriesParent, true, isAlwaysTrue);28 29 const 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 linesmodified:test/ipc/outgoing.js+5 added-5 removed
1 import test from 'ava';2 import {execa} from '../../index.js';3 import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {foobarString} from '../helpers/input.js';5-import {alwaysPass, subprocessGetOne, subprocessGetFirst} from '../helpers/ipc.js';5+import {isAlwaysTrue, subprocessGetOne, subprocessGetFirst} from '../helpers/ipc.js';6 import {PARALLEL_COUNT} from '../helpers/parallel.js';7 8 setFixtureDirectory();9 19 unmodified lines29 };30 31 test('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer false', testSendHoldParent, subprocessGetOne, false, undefined);32 test('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer true', testSendHoldParent, subprocessGetOne, true, undefined);33-test('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer false, filter', testSendHoldParent, subprocessGetOne, false, alwaysPass);34-test('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer true, filter', testSendHoldParent, subprocessGetOne, true, alwaysPass);33+test('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer false, filter', testSendHoldParent, subprocessGetOne, false, isAlwaysTrue);34+test('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer true, filter', testSendHoldParent, subprocessGetOne, true, isAlwaysTrue);35 test('Multiple parallel subprocess.sendMessage() + subprocess.getEachMessage(), buffer false', testSendHoldParent, subprocessGetFirst, false, undefined);36 test('Multiple parallel subprocess.sendMessage() + subprocess.getEachMessage(), buffer true', testSendHoldParent, subprocessGetFirst, true, undefined);37 38 const testSendHoldSubprocess = async (t, filter, isGetEach) => {32 unmodified lines71 };72 73 test('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer false', testSendHoldParentSerial, subprocessGetOne, false, undefined);74 test('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer true', testSendHoldParentSerial, subprocessGetOne, true, undefined);75-test('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer false, filter', testSendHoldParentSerial, subprocessGetOne, false, alwaysPass);76-test('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer true, filter', testSendHoldParentSerial, subprocessGetOne, true, alwaysPass);75+test('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer false, filter', testSendHoldParentSerial, subprocessGetOne, false, isAlwaysTrue);76+test('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer true, filter', testSendHoldParentSerial, subprocessGetOne, true, isAlwaysTrue);77 test('Multiple serial subprocess.sendMessage() + subprocess.getEachMessage(), buffer false', testSendHoldParentSerial, subprocessGetFirst, false, undefined);78 test('Multiple serial subprocess.sendMessage() + subprocess.getEachMessage(), buffer true', testSendHoldParentSerial, subprocessGetFirst, true, undefined);79 80 const testSendHoldSubprocessSerial = async (t, filter, isGetEach) => {8 unmodified linesmodified:test/methods/main-async.js+1 added
61 unmodified lines62 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 linesmodified:test/pipe/methods.js+12 added-30 removed
34 unmodified lines35 await Promise.allSettled(subprocesses);36 };37 38 const 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());40 41 return messages;42 };43 44 test('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());46 47 t.deepEqual(lines, noNewlinesChunks);48 });49 50 test('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());52 53 t.deepEqual(lines, noNewlinesChunks);54 });55 16 unmodified lines72 t.is(secondOutput, simpleFull);73 });74 75 test('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}));77 78 t.deepEqual(chunks, noNewlinesChunks);79 t.is(chunks.join(''), noNewlinesFull);80 });45 unmodified lines126 });127 128 test('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'}));131 132 t.deepEqual(lines, ['aaa', 'bbb', 'ccc:stderr']);133 await piped;134 });80 unmodified lines215 abortController.abort();216 await Promise.all(readerPromises.map(async readerPromise => assertSettles(t, readerPromise)));217 });218 234-const assertCanceledPipeMessageReader = async (t, getReader, abortBeforePipe = false) => {219+const assertCanceledPipeMessageReader = async (t, getReader, shouldAbortBeforePipe = false) => {220 const abortController = new AbortController();236- if (abortBeforePipe) {221+ if (shouldAbortBeforePipe) {222 abortController.abort();223 }224 225 const source = execa('noop-repeat.js');4 unmodified lines230 231 const piped = source.pipe(destination, {unpipeSignal: abortController.signal});232 const readerPromise = t.throwsAsync(getReader(piped), {message: /Pipe canceled/});233 249- if (!abortBeforePipe) {234+ if (!shouldAbortBeforePipe) {235 abortController.abort();236 }237 238 await assertSettles(t, readerPromise);98 unmodified lines337 await piped;338 });339 340 test('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'));342 343 t.deepEqual(lines, noNewlinesChunks);344 });345 28 unmodified lines374 375 await t.throwsAsync(text(piped.all), {message: /Command failed with exit code 2/});376 });377 396-const assertCanceledPipeReader = async (t, getReader, abortBeforePipe = false) => {378+const assertCanceledPipeReader = async (t, getReader, shouldAbortBeforePipe = false) => {379 const abortController = new AbortController();398- if (abortBeforePipe) {380+ if (shouldAbortBeforePipe) {381 abortController.abort();382 }383 384 const source = execa('stdin.js');4 unmodified lines389 390 const piped = source.pipe(destination, {unpipeSignal: abortController.signal});391 const readerPromise = t.throwsAsync(getReader(piped), {message: /Pipe canceled/});392 411- if (!abortBeforePipe) {393+ if (!shouldAbortBeforePipe) {394 abortController.abort();395 }396 397 await assertSettles(t, readerPromise, 200);32 unmodified linesmodified:test/return/early-error.js+2 added-8 removed
125 unmodified lines126 test('child_process.spawn() early errors can use .getEachMessage()', testEarlyErrorIpc, subprocess => subprocess.getEachMessage());127 128 test('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());131 132 t.deepEqual(lines, []);133 await t.throwsAsync(subprocess);134 });135 136 test('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);139 140 t.deepEqual(lines, []);141 await t.throwsAsync(subprocess);142 });16 unmodified linesmodified:test/stdio/node-stream-custom.js+3 added-3 removed
61 unmodified lines62 test('stderr cannot be [Writable, "pipe"] without a file descriptor, sync', testLazyFileWritableSync, 2);63 test('stdio[*] cannot be [Writable, "pipe"] without a file descriptor, sync', testLazyFileWritableSync, 3);64 65 test('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 });78 79 test('Handles custom streams destroy errors on subprocess success', async t => {80 const cause = new Error('test');80 unmodified linesmodified:test/stdio/web-stream.js+3 added-3 removed
42 unmodified lines43 test('stderr cannot be a WritableStream - sync', testWebStreamSync, WritableStream, 2, 'stderr');44 test('stdio[*] cannot be a WritableStream - sync', testWebStreamSync, WritableStream, 3, 'stdio[3]');45 46 const 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 };57 58 test('stdout waits for WritableStream completion', testLongWritableStream, 1);59 test('stderr waits for WritableStream completion', testLongWritableStream, 2);39 unmodified linesmodified:test/transform/encoding-multibyte.js+1 added-1 removed
20 unmodified lines21 });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 linesmodified:test/verbose/output-progressive.js+5 added-5 removed
25 unmodified lines26 27 test.serial('Prints stdout progressively, interleaved', async t => {28 const subprocess = nestedInstance('noop-repeat.js', ['1', `${foobarString}\n`], {parentFixture: 'nested-double.js', verbose: 'full'});29 30- 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 }37 38 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 }45 46- if (firstSubprocessPrinted && secondSubprocessPrinted) {46+ if (isFirstSubprocessPrinted && isSecondSubprocessPrinted) {47 break;48 }49 }50 11 unmodified linesmodified:test-d/return/result-stdio.test-d.ts+3 added-3 removed
121 unmodified lines122 123 const outputPipeFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'pipe'}]});124 expectType<string>(outputPipeFd3Result.stdio[3]);125 126-const input = true as boolean;127-const booleanInputPipeFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'pipe', input}]});126+const isInput = true as boolean;127+const booleanInputPipeFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'pipe', input: isInput}]});128 expectType<string | undefined>(booleanInputPipeFd3Result.stdio[3]);129 130-const optionalInputPipe: {readonly value: 'pipe'; readonly input?: boolean} = {value: 'pipe', input};130+const optionalInputPipe: {readonly value: 'pipe'; readonly input?: boolean} = {value: 'pipe', input: isInput};131 const optionalInputPipeFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', optionalInputPipe]});132 expectType<string | undefined>(optionalInputPipeFd3Result.stdio[3]);133 134 const optionalTrueInputPipe: {readonly value: 'pipe'; readonly input?: true} = {value: 'pipe', input: true};22 unmodified linesmodified:test-d/stdio/option/generator-boolean-full.test-d.ts+1 added
7 unmodified lines8 type StdoutStderrSyncOption,9 } from '../../../index.js';10 11 const 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 linesmodified:test-d/stdio/option/generator-boolean.test-d.ts+1 added
6 unmodified lines7 type StdoutStderrOption,8 type StdoutStderrSyncOption,9 } from '../../../index.js';10 11+// 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.12 const booleanGenerator = function * (line: boolean) {13 yield line;14 };15 32 unmodified linesmodified:test-d/stdio/option/input-pipe.test-d.ts+2 added-2 removed
8 unmodified lines9 type StdoutStderrSyncOption,10 } from '../../../index.js';11 12 const inputPipe = {value: 'pipe', input: true} as const;13-const input = true as boolean;14-const booleanInputPipe = {value: 'pipe', input} as const;13+const isInput = true as boolean;14+const booleanInputPipe = {value: 'pipe', input: isInput} as const;15 const transform = function * (line: string) {16 yield line;17 };18 46 unmodified linesmodified:test-d/subprocess/stdio.test-d.ts+3 added-3 removed
53 unmodified lines54 55 const inputFileSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: {file: './example'}, input: true}]});56 expectType<Writable>(inputFileSubprocess.stdio[3]);57 58-const input = true as boolean;59-const booleanInputPipeSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'pipe', input}]});58+const isInput = true as boolean;59+const booleanInputPipeSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {value: 'pipe', input: isInput}]});60 expectType<Readable | Writable>(booleanInputPipeSubprocess.stdio[3]);61 62-const optionalInputPipe: {readonly value: 'pipe'; readonly input?: boolean} = {value: 'pipe', input};62+const optionalInputPipe: {readonly value: 'pipe'; readonly input?: boolean} = {value: 'pipe', input: isInput};63 const optionalInputPipeSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', optionalInputPipe]});64 expectType<Readable | Writable>(optionalInputPipeSubprocess.stdio[3]);65 66 const optionalTrueInputPipe: {readonly value: 'pipe'; readonly input?: true} = {value: 'pipe', input: true};10 unmodified linesmodified:test-d/verbose.test-d.ts+2 added
44 unmodified lines45 await execa('unicorns', {verbose: (verboseLine: string) => ''});46 execaSync('unicorns', {verbose: (verboseLine: string) => ''});47 await execa('unicorns', {verbose: (verboseLine: unknown) => ''});48 execaSync('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.50 expectError(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.52 expectError(execaSync('unicorns', {verbose: (verboseLine: boolean) => ''}));53 expectError(await execa('unicorns', {verbose: (verboseLine: never) => ''}));54 expectError(execaSync('unicorns', {verbose: (verboseLine: never) => ''}));55 44 unmodified linesmodified:package.json+1 added-1 removed
75 unmodified lines76 "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