Upgrade xo (#980)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent 0bd0f0d · Browse files · 193 files·+1505 added−686 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
193 files+1505 added−686 removed
- tests:+741 added−493 removed
- other:+764 added−193 removed
Provenance
- Commit
ccfa412- Tree
64df87f- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
0bd0f0d
193 files changed+1505 added−686 removed
modified:lib/arguments/command.js+8 added-3 removed
2 unmodified lines345677899101112121314151617182 unmodified linesimport {getStartTime} from '../return/duration.js';import {joinCommand} from './escape.js';import {normalizeFdSpecificOption} from './specific.js';
export const handleCommand = (filePath, rawArgs, rawOptions) => {export const handleCommand = (filePath, rawArguments, rawOptions) => { const startTime = getStartTime(); const {command, escapedCommand} = joinCommand(filePath, rawArgs); const {command, escapedCommand} = joinCommand(filePath, rawArguments); const verboseInfo = getVerboseInfo(normalizeFdSpecificOption(rawOptions, 'verbose')); logCommand(escapedCommand, verboseInfo, rawOptions); return {command, escapedCommand, startTime, verboseInfo}; return { command, escapedCommand, startTime, verboseInfo, };};modified:lib/arguments/escape.js+11 added-9 removed
12345674567891011121342 unmodified lines5657585958596060616263646564656667686970import {platform} from 'node:process';import {stripVTControlCharacters} from 'node:util';
export const joinCommand = (filePath, rawArgs) => { const fileAndArgs = [filePath, ...rawArgs]; const command = fileAndArgs.join(' '); const escapedCommand = fileAndArgs.map(arg => quoteString(escapeControlCharacters(arg))).join(' ');export const joinCommand = (filePath, rawArguments) => { const fileAndArguments = [filePath, ...rawArguments]; const command = fileAndArguments.join(' '); const escapedCommand = fileAndArguments .map(fileAndArgument => quoteString(escapeControlCharacters(fileAndArgument))) .join(' '); return {command, escapedCommand};};
export const escapeLines = lines => stripVTControlCharacters(lines)42 unmodified lines// Escaping is shell-specific. We cannot know which shell is used: `process.platform` detection is not enough.// For example, Windows users could be using `cmd.exe`, Powershell or Bash for Windows which all use different escaping.// We use '...' on Unix, which is POSIX shell compliant and escape all characters but ' so this is fairly safe.// On Windows, we assume cmd.exe is used and escape with "...", which also works with Powershell.const quoteString = escapedArg => { if (NO_ESCAPE_REGEXP.test(escapedArg)) { return escapedArg;const quoteString = escapedArgument => { if (NO_ESCAPE_REGEXP.test(escapedArgument)) { return escapedArgument; }
return platform === 'win32' ? `"${escapedArg.replaceAll('"', '""')}"` : `'${escapedArg.replaceAll('\'', '\'\\\'\'')}'`; ? `"${escapedArgument.replaceAll('"', '""')}"` : `'${escapedArgument.replaceAll('\'', '\'\\\'\'')}'`;};
const NO_ESCAPE_REGEXP = /^[\w./-]+$/;modified:lib/arguments/options.js+15 added-9 removed
8 unmodified lines91011121313141515161717181920214 unmodified lines262728293030313233333435363738394040414243447 unmodified lines525354555656575859603 unmodified lines6465666768686970717272737475767778798081828 unmodified linesimport {normalizeCwd} from './cwd.js';import {normalizeFileUrl} from './file-url.js';import {normalizeFdSpecificOptions} from './specific.js';
export const handleOptions = (filePath, rawArgs, rawOptions) => {export const handleOptions = (filePath, rawArguments, rawOptions) => { rawOptions.cwd = normalizeCwd(rawOptions.cwd); const [processedFile, processedArgs, processedOptions] = handleNodeOption(filePath, rawArgs, rawOptions); const [processedFile, processedArguments, processedOptions] = handleNodeOption(filePath, rawArguments, rawOptions);
const {command: file, args, options: initialOptions} = crossSpawn._parse(processedFile, processedArgs, processedOptions); const {command: file, args: commandArguments, options: initialOptions} = crossSpawn._parse(processedFile, processedArguments, processedOptions);
const fdOptions = normalizeFdSpecificOptions(initialOptions); const options = addDefaultOptions(fdOptions); validateTimeout(options);4 unmodified lines options.lines = options.lines.map((lines, fdNumber) => lines && !BINARY_ENCODINGS.has(options.encoding) && options.buffer[fdNumber]);
if (process.platform === 'win32' && basename(file, '.exe') === 'cmd') { // #116 args.unshift('/q'); commandArguments.unshift('/q'); }
return {file, args, options}; return {file, commandArguments, options};};
const addDefaultOptions = ({ extendEnv = true, preferLocal = false, cwd, localDir = cwd, localDir: localDirectory = cwd, encoding = 'utf8', reject = true, cleanup = true, all = false,7 unmodified lines ...options, extendEnv, preferLocal, cwd, localDir, localDirectory, encoding, reject, cleanup, all,3 unmodified lines ipc, serialization,});
const getEnv = ({env: envOption, extendEnv, preferLocal, node, localDir, nodePath}) => {const getEnv = ({env: envOption, extendEnv, preferLocal, node, localDirectory, nodePath}) => { const env = extendEnv ? {...process.env, ...envOption} : envOption;
if (preferLocal || node) { return npmRunPathEnv({env, cwd: localDir, execPath: nodePath, preferLocal, addExecPath: node}); return npmRunPathEnv({ env, cwd: localDirectory, execPath: nodePath, preferLocal, addExecPath: node, }); }
return env;};modified:lib/convert/duplex.js+28 added-4 removed
19 unmodified lines20 const binary = binaryOption || BINARY_ENCODINGS.has(encoding);21 const {subprocessStdout, waitReadableDestroy} = getSubprocessStdout(subprocess, from, concurrentStreams);22 const {subprocessStdin, waitWritableFinal, waitWritableDestroy} = getSubprocessStdin(subprocess, to, concurrentStreams);23 const {readableEncoding, readableObjectMode, readableHighWaterMark} = getReadableOptions(subprocessStdout, binary);24- const {read, onStdoutDataDone} = getReadableMethods({subprocessStdout, subprocess, binary, encoding, preserveNewlines});24+ const {read, onStdoutDataDone} = getReadableMethods({25+ subprocessStdout,26+ subprocess,27+ binary,28+ encoding,29+ preserveNewlines,30+ });31 const duplex = new Duplex({32 read,33 ...getWritableMethods(subprocessStdin, subprocess, waitWritableFinal),28- destroy: callbackify(onDuplexDestroy.bind(undefined, {subprocessStdout, subprocessStdin, subprocess, waitReadableDestroy, waitWritableFinal, waitWritableDestroy})),34+ destroy: callbackify(onDuplexDestroy.bind(undefined, {35+ subprocessStdout,36+ subprocessStdin,37+ subprocess,38+ waitReadableDestroy,39+ waitWritableFinal,40+ waitWritableDestroy,41+ })),42 readableHighWaterMark,43 writableHighWaterMark: subprocessStdin.writableHighWaterMark,44 readableObjectMode,45 writableObjectMode: subprocessStdin.writableObjectMode,46 encoding: readableEncoding,47 });35- onStdoutFinished({subprocessStdout, onStdoutDataDone, readable: duplex, subprocess, subprocessStdin});48+ onStdoutFinished({49+ subprocessStdout,50+ onStdoutDataDone,51+ readable: duplex,52+ subprocess,53+ subprocessStdin,54+ });55 onStdinFinished(subprocessStdin, duplex, subprocessStdout);56 return duplex;57 };58 59 const onDuplexDestroy = async ({subprocessStdout, subprocessStdin, subprocess, waitReadableDestroy, waitWritableFinal, waitWritableDestroy}, error) => {60 await Promise.all([61 onReadableDestroy({subprocessStdout, subprocess, waitReadableDestroy}, error),43- onWritableDestroy({subprocessStdin, subprocess, waitWritableFinal, waitWritableDestroy}, error),62+ onWritableDestroy({63+ subprocessStdin,64+ subprocess,65+ waitWritableFinal,66+ waitWritableDestroy,67+ }, error),68 ]);69 };modified:lib/convert/iterable.js+8 added-1 removed
7 unmodified lines8910111212131415161718192021222310 unmodified lines7 unmodified lines preserveNewlines = false,} = {}) => { const binary = binaryOption || BINARY_ENCODINGS.has(encoding); const subprocessStdout = getReadable(subprocess, from); const onStdoutData = iterateOnSubprocessStream({subprocessStdout, subprocess, binary, shouldEncode: true, encoding, preserveNewlines}); const onStdoutData = iterateOnSubprocessStream({ subprocessStdout, subprocess, binary, shouldEncode: true, encoding, preserveNewlines, }); return iterateOnStdoutData(onStdoutData, subprocessStdout, subprocess);};
const iterateOnStdoutData = async function * (onStdoutData, subprocessStdout, subprocess) {10 unmodified linesmodified:lib/convert/readable.js+21 added-3 removed
15 unmodified lines16 export const createReadable = ({subprocess, concurrentStreams, encoding}, {from, binary: binaryOption = true, preserveNewlines = true} = {}) => {17 const binary = binaryOption || BINARY_ENCODINGS.has(encoding);18 const {subprocessStdout, waitReadableDestroy} = getSubprocessStdout(subprocess, from, concurrentStreams);19 const {readableEncoding, readableObjectMode, readableHighWaterMark} = getReadableOptions(subprocessStdout, binary);20- const {read, onStdoutDataDone} = getReadableMethods({subprocessStdout, subprocess, binary, encoding, preserveNewlines});20+ const {read, onStdoutDataDone} = getReadableMethods({21+ subprocessStdout,22+ subprocess,23+ binary,24+ encoding,25+ preserveNewlines,26+ });27 const readable = new Readable({28 read,29 destroy: callbackify(onReadableDestroy.bind(undefined, {subprocessStdout, subprocess, waitReadableDestroy})),30 highWaterMark: readableHighWaterMark,31 objectMode: readableObjectMode,32 encoding: readableEncoding,33 });28- onStdoutFinished({subprocessStdout, onStdoutDataDone, readable, subprocess});34+ onStdoutFinished({35+ subprocessStdout,36+ onStdoutDataDone,37+ readable,38+ subprocess,39+ });40 return readable;41 };42 43 // Retrieve `stdout` (or other stream depending on `from`)8 unmodified lines52 : {readableEncoding, readableObjectMode: true, readableHighWaterMark: DEFAULT_OBJECT_HIGH_WATER_MARK};53 54 export const getReadableMethods = ({subprocessStdout, subprocess, binary, encoding, preserveNewlines}) => {55 const onStdoutDataDone = createDeferred();45- const onStdoutData = iterateOnSubprocessStream({subprocessStdout, subprocess, binary, shouldEncode: !binary, encoding, preserveNewlines});56+ const onStdoutData = iterateOnSubprocessStream({57+ subprocessStdout,58+ subprocess,59+ binary,60+ shouldEncode: !binary,61+ encoding,62+ preserveNewlines,63+ });64 65 return {66 read() {67 onRead(this, onStdoutData, onStdoutDataDone);46 unmodified linesmodified:lib/convert/writable.js+6 added-1 removed
12 unmodified lines13 export const createWritable = ({subprocess, concurrentStreams}, {to} = {}) => {14 const {subprocessStdin, waitWritableFinal, waitWritableDestroy} = getSubprocessStdin(subprocess, to, concurrentStreams);15 const writable = new Writable({16 ...getWritableMethods(subprocessStdin, subprocess, waitWritableFinal),17- destroy: callbackify(onWritableDestroy.bind(undefined, {subprocessStdin, subprocess, waitWritableFinal, waitWritableDestroy})),17+ destroy: callbackify(onWritableDestroy.bind(undefined, {18+ subprocessStdin,19+ subprocess,20+ waitWritableFinal,21+ waitWritableDestroy,22+ })),23 highWaterMark: subprocessStdin.writableHighWaterMark,24 objectMode: subprocessStdin.writableObjectMode,25 });26 onStdinFinished(subprocessStdin, writable);64 unmodified linesmodified:lib/io/contents.js+38 added-5 removed
5 unmodified lines6 import {handleMaxBuffer} from './max-buffer.js';7 import {getStripFinalNewline} from './strip-newline.js';8 9 export const getStreamOutput = async ({stream, onStreamEnd, fdNumber, encoding, buffer, maxBuffer, lines, allMixed, stripFinalNewline, verboseInfo, streamInfo: {fileDescriptors}}) => {10- if (shouldLogOutput({stdioItems: fileDescriptors[fdNumber]?.stdioItems, encoding, verboseInfo, fdNumber})) {11- const linesIterable = iterateForResult({stream, onStreamEnd, lines: true, encoding, stripFinalNewline: true, allMixed});10+ if (shouldLogOutput({11+ stdioItems: fileDescriptors[fdNumber]?.stdioItems,12+ encoding,13+ verboseInfo,14+ fdNumber,15+ })) {16+ const linesIterable = iterateForResult({17+ stream,18+ onStreamEnd,19+ lines: true,20+ encoding,21+ stripFinalNewline: true,22+ allMixed,23+ });24 logLines(linesIterable, stream, verboseInfo);25 }26 27 if (!buffer) {1 unmodified line29 return;30 }31 32 const stripFinalNewlineValue = getStripFinalNewline(stripFinalNewline, fdNumber);21- const iterable = iterateForResult({stream, onStreamEnd, lines, encoding, stripFinalNewline: stripFinalNewlineValue, allMixed});22- return getStreamContents({stream, iterable, fdNumber, encoding, maxBuffer, lines});33+ const iterable = iterateForResult({34+ stream,35+ onStreamEnd,36+ lines,37+ encoding,38+ stripFinalNewline: stripFinalNewlineValue,39+ allMixed,40+ });41+ return getStreamContents({42+ stream,43+ iterable,44+ fdNumber,45+ encoding,46+ maxBuffer,47+ lines,48+ });49 };50 51 // When using `buffer: false`, users need to read `subprocess.stdout|stderr|all` right away52 // See https://github.com/sindresorhus/execa/issues/730 and https://github.com/sindresorhus/execa/pull/729#discussion_r146549631015 unmodified lines68 }69 70 return await getStream(iterable, {maxBuffer});71 } catch (error) {46- return handleBufferedData(handleMaxBuffer({error, stream, readableObjectMode, lines, encoding, fdNumber}));72+ return handleBufferedData(handleMaxBuffer({73+ error,74+ stream,75+ readableObjectMode,76+ lines,77+ encoding,78+ fdNumber,79+ }));80 }81 };82 83 // On failure, `result.stdout|stderr|all` should contain the currently buffered stream13 unmodified linesmodified:lib/io/iterate.js+16 added-2 removed
60 unmodified lines61 // See https://github.com/nodejs/node/pull/52080#discussion_r152522786162 // @todo Remove after removing support for Node 2163 highWatermark: HIGH_WATER_MARK,64 });65- return iterateOnData({onStdoutChunk, controller, binary, shouldEncode, encoding, shouldSplit, preserveNewlines});65+ return iterateOnData({66+ onStdoutChunk,67+ controller,68+ binary,69+ shouldEncode,70+ encoding,71+ shouldSplit,72+ preserveNewlines,73+ });74 };75 76 // @todo: replace with `getDefaultHighWaterMark(true)` after dropping support for Node <18.17.077 export const DEFAULT_OBJECT_HIGH_WATER_MARK = 16;4 unmodified lines82 // Note: this option does not exist on Node 18, but this is ok since the logic works without it. It just consumes more memory.83 const HIGH_WATER_MARK = DEFAULT_OBJECT_HIGH_WATER_MARK;84 85 const iterateOnData = async function * ({onStdoutChunk, controller, binary, shouldEncode, encoding, shouldSplit, preserveNewlines}) {78- const generators = getGenerators({binary, shouldEncode, encoding, shouldSplit, preserveNewlines});86+ const generators = getGenerators({87+ binary,88+ shouldEncode,89+ encoding,90+ shouldSplit,91+ preserveNewlines,92+ });93 94 try {95 for await (const [chunk] of onStdoutChunk) {96 yield * transformChunkSync(chunk, generators, 0);14 unmodified linesmodified:lib/io/output-async.js+8 added-1 removed
13 unmodified lines14 pipeTransform(subprocess, stream, direction, fdNumber);15 }16 17 for (const {stream} of stdioItems.filter(({type}) => !TRANSFORM_TYPES.has(type))) {18- pipeStdioItem({subprocess, stream, direction, fdNumber, inputStreamsGroups, controller});18+ pipeStdioItem({19+ subprocess,20+ stream,21+ direction,22+ fdNumber,23+ inputStreamsGroups,24+ controller,25+ });26 }27 }28 29 for (const [fdNumber, inputStreams] of Object.entries(inputStreamsGroups)) {49 unmodified linesmodified:lib/io/output-sync.js+22 added-6 removed
12 unmodified lines13 }14 15 const state = {};16 const transformedOutput = output.map((result, fdNumber) =>17- transformOutputResultSync({result, fileDescriptors, fdNumber, state, isMaxBuffer, verboseInfo}, options));17+ transformOutputResultSync({18+ result,19+ fileDescriptors,20+ fdNumber,21+ state,22+ isMaxBuffer,23+ verboseInfo,24+ }, options));25 return {output: transformedOutput, ...state};26 };27 28 const transformOutputResultSync = ({result, fileDescriptors, fdNumber, state, isMaxBuffer, verboseInfo}, {buffer, encoding, lines, stripFinalNewline, maxBuffer}) => {4 unmodified lines33 const truncatedResult = truncateResult(result, isMaxBuffer, getMaxBufferSync(maxBuffer));34 const uint8ArrayResult = bufferToUint8Array(truncatedResult);35 const {stdioItems, objectMode} = fileDescriptors[fdNumber];36 const chunks = runOutputGeneratorsSync([uint8ArrayResult], stdioItems, encoding, state);30- const {31- serializedResult,32- finalResult = serializedResult,33- } = serializeChunks({chunks, objectMode, encoding, lines, stripFinalNewline, fdNumber});37+ const {serializedResult, finalResult = serializedResult} = serializeChunks({38+ chunks,39+ objectMode,40+ encoding,41+ lines,42+ stripFinalNewline,43+ fdNumber,44+ });45 35- if (shouldLogOutput({stdioItems, encoding, verboseInfo, fdNumber})) {46+ if (shouldLogOutput({47+ stdioItems,48+ encoding,49+ verboseInfo,50+ fdNumber,51+ })) {52 const linesArray = splitLinesSync(serializedResult, false, objectMode);53 logLinesSync(linesArray, verboseInfo);54 }55 51 unmodified linesmodified:lib/methods/command.js+7 added-7 removed
1-export const mapCommandAsync = ({file, args}) => parseCommand(file, args);2-export const mapCommandSync = ({file, args}) => ({...parseCommand(file, args), isSync: true});1+export const mapCommandAsync = ({file, commandArguments}) => parseCommand(file, commandArguments);2+export const mapCommandSync = ({file, commandArguments}) => ({...parseCommand(file, commandArguments), isSync: true});3 4-const parseCommand = (command, unusedArgs) => {5- if (unusedArgs.length > 0) {6- throw new TypeError(`The command and its arguments must be passed as a single string: ${command} ${unusedArgs}.`);4+const parseCommand = (command, unusedArguments) => {5+ if (unusedArguments.length > 0) {6+ throw new TypeError(`The command and its arguments must be passed as a single string: ${command} ${unusedArguments}.`);7 }8 9 const tokens = [];10 for (const token of command.trim().split(SPACES_REGEXP)) {6 unmodified lines17 tokens.push(token);18 }19 }20 21- const [file, ...args] = tokens;22- return {file, args};21+ const [file, ...commandArguments] = tokens;22+ return {file, commandArguments};23 };24 25 const SPACES_REGEXP = / +/g;modified:lib/methods/create.js+27 added-10 removed
5 unmodified lines6 import {execaCoreAsync} from './main-async.js';7 8 export const createExeca = (mapArguments, boundOptions, deepOptions, setBoundExeca) => {9 const createNested = (mapArguments, boundOptions, setBoundExeca) => createExeca(mapArguments, boundOptions, deepOptions, setBoundExeca);10- const boundExeca = (...args) => callBoundExeca({mapArguments, deepOptions, boundOptions, setBoundExeca, createNested}, ...args);10+ const boundExeca = (...execaArguments) => callBoundExeca({11+ mapArguments,12+ deepOptions,13+ boundOptions,14+ setBoundExeca,15+ createNested,16+ }, ...execaArguments);17 18 if (setBoundExeca !== undefined) {19 setBoundExeca(boundExeca, createNested, boundOptions);20 }5 unmodified lines26 if (isPlainObject(firstArgument)) {27 return createNested(mapArguments, mergeOptions(boundOptions, firstArgument), setBoundExeca);28 }29 24- const {file, args, options, isSync} = parseArguments({mapArguments, firstArgument, nextArguments, deepOptions, boundOptions});30+ const {file, commandArguments, options, isSync} = parseArguments({31+ mapArguments,32+ firstArgument,33+ nextArguments,34+ deepOptions,35+ boundOptions,36+ });37 return isSync26- ? execaCoreSync(file, args, options)27- : execaCoreAsync(file, args, options, createNested);38+ ? execaCoreSync(file, commandArguments, options)39+ : execaCoreAsync(file, commandArguments, options, createNested);40 };41 42 const parseArguments = ({mapArguments, firstArgument, nextArguments, deepOptions, boundOptions}) => {43 const callArguments = isTemplateString(firstArgument)44 ? parseTemplates(firstArgument, nextArguments)45 : [firstArgument, ...nextArguments];34- const [rawFile, rawArgs, rawOptions] = normalizeParameters(...callArguments);35- const mergedOptions = mergeOptions(mergeOptions(deepOptions, boundOptions), rawOptions);46+ const [initialFile, initialArguments, initialOptions] = normalizeParameters(...callArguments);47+ const mergedOptions = mergeOptions(mergeOptions(deepOptions, boundOptions), initialOptions);48 const {37- file = rawFile,38- args = rawArgs,49+ file = initialFile,50+ commandArguments = initialArguments,51 options = mergedOptions,52 isSync = false,41- } = mapArguments({file: rawFile, args: rawArgs, options: mergedOptions});42- return {file, args, options, isSync};53+ } = mapArguments({file: initialFile, commandArguments: initialArguments, options: mergedOptions});54+ return {55+ file,56+ commandArguments,57+ options,58+ isSync,59+ };60 };61 62 // Deep merge specific options like `env`. Shallow merge the other ones.63 const mergeOptions = (boundOptions, options) => {18 unmodified linesmodified:lib/methods/main-async.js+88 added-21 removed
17 unmodified lines18 import {waitForSubprocessResult} from '../resolve/wait-subprocess.js';19 import {addConvertedStreams} from '../convert/add.js';20 import {mergePromise} from './promise.js';21 22-export const execaCoreAsync = (rawFile, rawArgs, rawOptions, createNested) => {23- const {file, args, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors} = handleAsyncArguments(rawFile, rawArgs, rawOptions);24- const {subprocess, promise} = spawnSubprocessAsync({file, args, options, startTime, verboseInfo, command, escapedCommand, fileDescriptors});25- subprocess.pipe = pipeToSubprocess.bind(undefined, {source: subprocess, sourcePromise: promise, boundOptions: {}, createNested});22+export const execaCoreAsync = (rawFile, rawArguments, rawOptions, createNested) => {23+ const {file, commandArguments, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors} = handleAsyncArguments(rawFile, rawArguments, rawOptions);24+ const {subprocess, promise} = spawnSubprocessAsync({25+ file,26+ commandArguments,27+ options,28+ startTime,29+ verboseInfo,30+ command,31+ escapedCommand,32+ fileDescriptors,33+ });34+ subprocess.pipe = pipeToSubprocess.bind(undefined, {35+ source: subprocess,36+ sourcePromise: promise,37+ boundOptions: {},38+ createNested,39+ });40 mergePromise(subprocess, promise);41 SUBPROCESS_OPTIONS.set(subprocess, {options, fileDescriptors});42 return subprocess;43 };44 31-const handleAsyncArguments = (rawFile, rawArgs, rawOptions) => {32- const {command, escapedCommand, startTime, verboseInfo} = handleCommand(rawFile, rawArgs, rawOptions);45+const handleAsyncArguments = (rawFile, rawArguments, rawOptions) => {46+ const {command, escapedCommand, startTime, verboseInfo} = handleCommand(rawFile, rawArguments, rawOptions);47 48 try {35- const {file, args, options: normalizedOptions} = handleOptions(rawFile, rawArgs, rawOptions);49+ const {file, commandArguments, options: normalizedOptions} = handleOptions(rawFile, rawArguments, rawOptions);50 const options = handleAsyncOptions(normalizedOptions);51 const fileDescriptors = handleStdioAsync(options, verboseInfo);38- return {file, args, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors};52+ return {53+ file,54+ commandArguments,55+ command,56+ escapedCommand,57+ startTime,58+ verboseInfo,59+ options,60+ fileDescriptors,61+ };62 } catch (error) {63 logEarlyResult(error, startTime, verboseInfo);64 throw error;65 }7 unmodified lines73 74 return {...options, timeoutDuration: timeout, signal: cancelSignal};75 };76 54-const spawnSubprocessAsync = ({file, args, options, startTime, verboseInfo, command, escapedCommand, fileDescriptors}) => {77+const spawnSubprocessAsync = ({file, commandArguments, options, startTime, verboseInfo, command, escapedCommand, fileDescriptors}) => {78 let subprocess;79 try {57- subprocess = spawn(file, args, options);80+ subprocess = spawn(file, commandArguments, options);81 } catch (error) {59- return handleEarlyError({error, command, escapedCommand, fileDescriptors, options, startTime, verboseInfo});82+ return handleEarlyError({83+ error,84+ command,85+ escapedCommand,86+ fileDescriptors,87+ options,88+ startTime,89+ verboseInfo,90+ });91 }92 93 const controller = new AbortController();94 setMaxListeners(Number.POSITIVE_INFINITY, controller.signal);1 unmodified line96 const originalStreams = [...subprocess.stdio];97 pipeOutputAsync(subprocess, fileDescriptors, controller);98 cleanupOnExit(subprocess, options, controller);99 69- subprocess.kill = subprocessKill.bind(undefined, {kill: subprocess.kill.bind(subprocess), subprocess, options, controller});100+ subprocess.kill = subprocessKill.bind(undefined, {101+ kill: subprocess.kill.bind(subprocess),102+ subprocess,103+ options,104+ controller,105+ });106 subprocess.all = makeAllStream(subprocess, options);107 addConvertedStreams(subprocess, options);108 73- const promise = handlePromise({subprocess, options, startTime, verboseInfo, fileDescriptors, originalStreams, command, escapedCommand, controller});109+ const promise = handlePromise({110+ subprocess,111+ options,112+ startTime,113+ verboseInfo,114+ fileDescriptors,115+ originalStreams,116+ command,117+ escapedCommand,118+ controller,119+ });120 return {subprocess, promise};121 };122 123 const handlePromise = async ({subprocess, options, startTime, verboseInfo, fileDescriptors, originalStreams, command, escapedCommand, controller}) => {124 const context = {timedOut: false};125 80- const [81- errorInfo,82- [exitCode, signal],83- stdioResults,84- allResult,85- ] = await waitForSubprocessResult({subprocess, options, context, verboseInfo, fileDescriptors, originalStreams, controller});126+ const [errorInfo, [exitCode, signal], stdioResults, allResult] = await waitForSubprocessResult({127+ subprocess,128+ options,129+ context,130+ verboseInfo,131+ fileDescriptors,132+ originalStreams,133+ controller,134+ });135 controller.abort();136 137 const stdio = stdioResults.map((stdioResult, fdNumber) => stripNewline(stdioResult, options, fdNumber));138 const all = stripNewline(allResult, options, 'all');90- const result = getAsyncResult({errorInfo, exitCode, signal, stdio, all, context, options, command, escapedCommand, startTime});139+ const result = getAsyncResult({140+ errorInfo,141+ exitCode,142+ signal,143+ stdio,144+ all,145+ context,146+ options,147+ command,148+ escapedCommand,149+ startTime,150+ });151 return handleResult(result, verboseInfo, options);152 };153 154 const getAsyncResult = ({errorInfo, exitCode, signal, stdio, all, context, options, command, escapedCommand, startTime}) => 'error' in errorInfo11 unmodified lines166 options,167 startTime,168 isSync: false,169 })110- : makeSuccessResult({command, escapedCommand, stdio, all, options, startTime});170+ : makeSuccessResult({171+ command,172+ escapedCommand,173+ stdio,174+ all,175+ options,176+ startTime,177+ });modified:lib/methods/main-sync.js+74 added-15 removed
10 unmodified lines11 import {logEarlyResult} from '../verbose/complete.js';12 import {getAllSync} from '../resolve/all-sync.js';13 import {getExitResultSync} from '../resolve/exit-sync.js';14 15-export const execaCoreSync = (rawFile, rawArgs, rawOptions) => {16- const {file, args, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors} = handleSyncArguments(rawFile, rawArgs, rawOptions);17- const result = spawnSubprocessSync({file, args, options, command, escapedCommand, verboseInfo, fileDescriptors, startTime});15+export const execaCoreSync = (rawFile, rawArguments, rawOptions) => {16+ const {file, commandArguments, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors} = handleSyncArguments(rawFile, rawArguments, rawOptions);17+ const result = spawnSubprocessSync({18+ file,19+ commandArguments,20+ options,21+ command,22+ escapedCommand,23+ verboseInfo,24+ fileDescriptors,25+ startTime,26+ });27 return handleResult(result, verboseInfo, options);28 };29 21-const handleSyncArguments = (rawFile, rawArgs, rawOptions) => {22- const {command, escapedCommand, startTime, verboseInfo} = handleCommand(rawFile, rawArgs, rawOptions);30+const handleSyncArguments = (rawFile, rawArguments, rawOptions) => {31+ const {command, escapedCommand, startTime, verboseInfo} = handleCommand(rawFile, rawArguments, rawOptions);32 33 try {34 const syncOptions = normalizeSyncOptions(rawOptions);26- const {file, args, options} = handleOptions(rawFile, rawArgs, syncOptions);35+ const {file, commandArguments, options} = handleOptions(rawFile, rawArguments, syncOptions);36 validateSyncOptions(options);37 const fileDescriptors = handleStdioSync(options, verboseInfo);29- return {file, args, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors};38+ return {39+ file,40+ commandArguments,41+ command,42+ escapedCommand,43+ startTime,44+ verboseInfo,45+ options,46+ fileDescriptors,47+ };48 } catch (error) {49 logEarlyResult(error, startTime, verboseInfo);50 throw error;51 }18 unmodified lines70 const throwInvalidSyncOption = value => {71 throw new TypeError(`The "${value}" option cannot be used with synchronous methods.`);72 };73 56-const spawnSubprocessSync = ({file, args, options, command, escapedCommand, verboseInfo, fileDescriptors, startTime}) => {57- const syncResult = runSubprocessSync({file, args, options, command, escapedCommand, fileDescriptors, startTime});74+const spawnSubprocessSync = ({file, commandArguments, options, command, escapedCommand, verboseInfo, fileDescriptors, startTime}) => {75+ const syncResult = runSubprocessSync({76+ file,77+ commandArguments,78+ options,79+ command,80+ escapedCommand,81+ fileDescriptors,82+ startTime,83+ });84 if (syncResult.failed) {85 return syncResult;86 }87 88 const {resultError, exitCode, signal, timedOut, isMaxBuffer} = getExitResultSync(syncResult, options);63- const {output, error = resultError} = transformOutputSync({fileDescriptors, syncResult, options, isMaxBuffer, verboseInfo});89+ const {output, error = resultError} = transformOutputSync({90+ fileDescriptors,91+ syncResult,92+ options,93+ isMaxBuffer,94+ verboseInfo,95+ });96 const stdio = output.map((stdioOutput, fdNumber) => stripNewline(stdioOutput, options, fdNumber));97 const all = stripNewline(getAllSync(output, options), options, 'all');66- return getSyncResult({error, exitCode, signal, timedOut, isMaxBuffer, stdio, all, options, command, escapedCommand, startTime});98+ return getSyncResult({99+ error,100+ exitCode,101+ signal,102+ timedOut,103+ isMaxBuffer,104+ stdio,105+ all,106+ options,107+ command,108+ escapedCommand,109+ startTime,110+ });111 };112 69-const runSubprocessSync = ({file, args, options, command, escapedCommand, fileDescriptors, startTime}) => {113+const runSubprocessSync = ({file, commandArguments, options, command, escapedCommand, fileDescriptors, startTime}) => {114 try {115 addInputOptionsSync(fileDescriptors, options);116 const normalizedOptions = normalizeSpawnSyncOptions(options);73- return spawnSync(file, args, normalizedOptions);117+ return spawnSync(file, commandArguments, normalizedOptions);118 } catch (error) {75- return makeEarlyError({error, command, escapedCommand, fileDescriptors, options, startTime, isSync: true});119+ return makeEarlyError({120+ error,121+ command,122+ escapedCommand,123+ fileDescriptors,124+ options,125+ startTime,126+ isSync: true,127+ });128 }129 };130 131 const normalizeSpawnSyncOptions = ({encoding, maxBuffer, ...options}) => ({...options, encoding: 'buffer', maxBuffer: getMaxBufferSync(maxBuffer)});132 133 const getSyncResult = ({error, exitCode, signal, timedOut, isMaxBuffer, stdio, all, options, command, escapedCommand, startTime}) => error === undefined82- ? makeSuccessResult({command, escapedCommand, stdio, all, options, startTime})134+ ? makeSuccessResult({135+ command,136+ escapedCommand,137+ stdio,138+ all,139+ options,140+ startTime,141+ })142 : makeError({143 error,144 command,145 escapedCommand,11 unmodified linesmodified:lib/methods/node.js+10 added-5 removed
8 unmodified lines9 10 return {options: {...options, node: true}};11 };12 13-export const handleNodeOption = (file, args, {13+export const handleNodeOption = (file, commandArguments, {14 node: shouldHandleNode = false,15 nodePath = execPath,16- nodeOptions = execArgv.filter(arg => !arg.startsWith('--inspect')),16+ nodeOptions = execArgv.filter(nodeOption => !nodeOption.startsWith('--inspect')),17 cwd,18 execPath: formerNodePath,19 ...options20 }) => {2 unmodified lines23 }24 25 const normalizedNodePath = safeNormalizeFileUrl(nodePath, 'The "nodePath" option');26 const resolvedNodePath = resolve(cwd, normalizedNodePath);27- const newOptions = {...options, nodePath: resolvedNodePath, node: shouldHandleNode, cwd};27+ const newOptions = {28+ ...options,29+ nodePath: resolvedNodePath,30+ node: shouldHandleNode,31+ cwd,32+ };33 34 if (!shouldHandleNode) {30- return [file, args, newOptions];35+ return [file, commandArguments, newOptions];36 }37 38 if (basename(file, '.exe') === 'node') {39 throw new TypeError('When the "node" option is true, the first argument does not need to be "node".');40 }41 42 return [43 resolvedNodePath,39- [...nodeOptions, file, ...args],44+ [...nodeOptions, file, ...commandArguments],45 {ipc: true, ...newOptions, shell: false},46 ];47 };modified:lib/methods/parameters.js+13 added-13 removed
1 import isPlainObject from 'is-plain-obj';2 import {safeNormalizeFileUrl} from '../arguments/file-url.js';3 4-export const normalizeParameters = (rawFile, rawArgs = [], rawOptions = {}) => {4+export const normalizeParameters = (rawFile, rawArguments = [], rawOptions = {}) => {5 const filePath = safeNormalizeFileUrl(rawFile, 'First argument');6- const [args, options] = isPlainObject(rawArgs)7- ? [[], rawArgs]8- : [rawArgs, rawOptions];6+ const [commandArguments, options] = isPlainObject(rawArguments)7+ ? [[], rawArguments]8+ : [rawArguments, rawOptions];9 10- if (!Array.isArray(args)) {11- throw new TypeError(`Second argument must be either an array of arguments or an options object: ${args}`);10+ if (!Array.isArray(commandArguments)) {11+ throw new TypeError(`Second argument must be either an array of arguments or an options object: ${commandArguments}`);12 }13 14- if (args.some(arg => typeof arg === 'object' && arg !== null)) {15- throw new TypeError(`Second argument must be an array of strings: ${args}`);14+ if (commandArguments.some(commandArgument => typeof commandArgument === 'object' && commandArgument !== null)) {15+ throw new TypeError(`Second argument must be an array of strings: ${commandArguments}`);16 }17 18- const normalizedArgs = args.map(String);19- const nullByteArg = normalizedArgs.find(arg => arg.includes('\0'));20- if (nullByteArg !== undefined) {21- throw new TypeError(`Arguments cannot contain null bytes ("\\0"): ${nullByteArg}`);18+ const normalizedArguments = commandArguments.map(String);19+ const nullByteArgument = normalizedArguments.find(normalizedArgument => normalizedArgument.includes('\0'));20+ if (nullByteArgument !== undefined) {21+ throw new TypeError(`Arguments cannot contain null bytes ("\\0"): ${nullByteArgument}`);22 }23 24 if (!isPlainObject(options)) {25 throw new TypeError(`Last argument must be an options object: ${options}`);26 }27 28- return [filePath, normalizedArgs, options];28+ return [filePath, normalizedArguments, options];29 };modified:lib/methods/template.js+9 added-3 removed
5 unmodified lines6 export const parseTemplates = (templates, expressions) => {7 let tokens = [];8 9 for (const [index, template] of templates.entries()) {10- tokens = parseTemplate({templates, expressions, tokens, index, template});10+ tokens = parseTemplate({11+ templates,12+ expressions,13+ tokens,14+ index,15+ template,16+ });17 }18 19 if (tokens.length === 0) {20 throw new TypeError('Template script must not be empty');21 }22 17- const [file, ...args] = tokens;18- return [file, args, {}];23+ const [file, ...commandArguments] = tokens;24+ return [file, commandArguments, {}];25 };26 27 const parseTemplate = ({templates, expressions, tokens, index, template}) => {28 if (template === undefined) {113 unmodified linesmodified:lib/pipe/abort.js+8 added-3 removed
1 import {aborted} from 'node:util';2 import {createNonCommandError} from './throw.js';3 4-export const unpipeOnAbort = (unpipeSignal, ...args) => unpipeSignal === undefined4+export const unpipeOnAbort = (unpipeSignal, unpipeContext) => unpipeSignal === undefined5 ? []6- : [unpipeOnSignalAbort(unpipeSignal, ...args)];6+ : [unpipeOnSignalAbort(unpipeSignal, unpipeContext)];7 8 const unpipeOnSignalAbort = async (unpipeSignal, {sourceStream, mergedStream, fileDescriptors, sourceOptions, startTime}) => {9 await aborted(unpipeSignal, sourceStream);10 await mergedStream.remove(sourceStream);11 const error = new Error('Pipe cancelled by `unpipeSignal` option.');12- throw createNonCommandError({error, fileDescriptors, sourceOptions, startTime});12+ throw createNonCommandError({13+ error,14+ fileDescriptors,15+ sourceOptions,16+ startTime,17+ });18 };modified:lib/pipe/pipe-arguments.js+15 added-10 removed
1 import {normalizeParameters} from '../methods/parameters.js';2 import {getStartTime} from '../return/duration.js';3 import {SUBPROCESS_OPTIONS, getWritable, getReadable} from '../arguments/fd-options.js';4 5-export const normalizePipeArguments = ({source, sourcePromise, boundOptions, createNested}, ...args) => {5+export const normalizePipeArguments = ({source, sourcePromise, boundOptions, createNested}, ...pipeArguments) => {6 const startTime = getStartTime();7 const {8 destination,9 destinationStream,10 destinationError,11 from,12 unpipeSignal,13- } = getDestinationStream(boundOptions, createNested, args);13+ } = getDestinationStream(boundOptions, createNested, pipeArguments);14 const {sourceStream, sourceError} = getSourceStream(source, from);15 const {options: sourceOptions, fileDescriptors} = SUBPROCESS_OPTIONS.get(source);16 return {17 sourcePromise,8 unmodified lines26 startTime,27 };28 };29 30-const getDestinationStream = (boundOptions, createNested, args) => {30+const getDestinationStream = (boundOptions, createNested, pipeArguments) => {31 try {32 const {33 destination,34 pipeOptions: {from, to, unpipeSignal} = {},35- } = getDestination(boundOptions, createNested, ...args);35+ } = getDestination(boundOptions, createNested, ...pipeArguments);36 const destinationStream = getWritable(destination, to);37- return {destination, destinationStream, from, unpipeSignal};37+ return {38+ destination,39+ destinationStream,40+ from,41+ unpipeSignal,42+ };43 } catch (error) {44 return {destinationError: error};45 }46 };47 43-const getDestination = (boundOptions, createNested, firstArgument, ...args) => {48+const getDestination = (boundOptions, createNested, firstArgument, ...pipeArguments) => {49 if (Array.isArray(firstArgument)) {45- const destination = createNested(mapDestinationArguments, boundOptions)(firstArgument, ...args);50+ const destination = createNested(mapDestinationArguments, boundOptions)(firstArgument, ...pipeArguments);51 return {destination, pipeOptions: boundOptions};52 }53 54 if (typeof firstArgument === 'string' || firstArgument instanceof URL) {55 if (Object.keys(boundOptions).length > 0) {56 throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');57 }58 54- const [rawFile, rawArgs, rawOptions] = normalizeParameters(firstArgument, ...args);55- const destination = createNested(mapDestinationArguments)(rawFile, rawArgs, rawOptions);59+ const [rawFile, rawArguments, rawOptions] = normalizeParameters(firstArgument, ...pipeArguments);60+ const destination = createNested(mapDestinationArguments)(rawFile, rawArguments, rawOptions);61 return {destination, pipeOptions: rawOptions};62 }63 64 if (SUBPROCESS_OPTIONS.has(firstArgument)) {65 if (Object.keys(boundOptions).length > 0) {66 throw new TypeError('Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).');67 }68 64- return {destination: firstArgument, pipeOptions: args[0]};69+ return {destination: firstArgument, pipeOptions: pipeArguments[0]};70 }71 72 throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${firstArgument}`);73 };11 unmodified linesmodified:lib/pipe/setup.js+17 added-6 removed
4 unmodified lines5 import {pipeSubprocessStream} from './streaming.js';6 import {unpipeOnAbort} from './abort.js';7 8 // Pipe a subprocess' `stdout`/`stderr`/`stdio` into another subprocess' `stdin`9-export const pipeToSubprocess = (sourceInfo, ...args) => {10- if (isPlainObject(args[0])) {9+export const pipeToSubprocess = (sourceInfo, ...pipeArguments) => {10+ if (isPlainObject(pipeArguments[0])) {11 return pipeToSubprocess.bind(undefined, {12 ...sourceInfo,13- boundOptions: {...sourceInfo.boundOptions, ...args[0]},13+ boundOptions: {...sourceInfo.boundOptions, ...pipeArguments[0]},14 });15 }16 17- const {destination, ...normalizedInfo} = normalizePipeArguments(sourceInfo, ...args);17+ const {destination, ...normalizedInfo} = normalizePipeArguments(sourceInfo, ...pipeArguments);18 const promise = handlePipePromise({...normalizedInfo, destination});19- promise.pipe = pipeToSubprocess.bind(undefined, {...sourceInfo, source: destination, sourcePromise: promise, boundOptions: {}});19+ promise.pipe = pipeToSubprocess.bind(undefined, {20+ ...sourceInfo,21+ source: destination,22+ sourcePromise: promise,23+ boundOptions: {},24+ });25 return promise;26 };27 28 const handlePipePromise = async ({22 unmodified lines51 try {52 const mergedStream = pipeSubprocessStream(sourceStream, destinationStream, maxListenersController);53 return await Promise.race([54 waitForBothSubprocesses(subprocessPromises),50- ...unpipeOnAbort(unpipeSignal, {sourceStream, mergedStream, sourceOptions, fileDescriptors, startTime}),55+ ...unpipeOnAbort(unpipeSignal, {56+ sourceStream,57+ mergedStream,58+ sourceOptions,59+ fileDescriptors,60+ startTime,61+ }),62 ]);63 } finally {64 maxListenersController.abort();65 }6 unmodified linesmodified:lib/pipe/throw.js+12 added-2 removed
8 unmodified lines9 fileDescriptors,10 sourceOptions,11 startTime,12 }) => {13- const error = getPipeArgumentsError({sourceStream, sourceError, destinationStream, destinationError});13+ const error = getPipeArgumentsError({14+ sourceStream,15+ sourceError,16+ destinationStream,17+ destinationError,18+ });19 if (error !== undefined) {15- throw createNonCommandError({error, fileDescriptors, sourceOptions, startTime});20+ throw createNonCommandError({21+ error,22+ fileDescriptors,23+ sourceOptions,24+ startTime,25+ });26 }27 };28 29 const getPipeArgumentsError = ({sourceStream, sourceError, destinationStream, destinationError}) => {26 unmodified linesmodified:lib/resolve/exit-sync.js+7 added-1 removed
4 unmodified lines5 export const getExitResultSync = ({error, status: exitCode, signal, output}, {maxBuffer}) => {6 const resultError = getResultError(error, exitCode, signal);7 const timedOut = resultError?.code === 'ETIMEDOUT';8 const isMaxBuffer = isMaxBufferSync(resultError, output, maxBuffer);9- return {resultError, exitCode, signal, timedOut, isMaxBuffer};9+ return {10+ resultError,11+ exitCode,12+ signal,13+ timedOut,14+ isMaxBuffer,15+ };16 };17 18 const getResultError = (error, exitCode, signal) => {19 if (error !== undefined) {5 unmodified linesmodified:lib/resolve/stdio.js+13 added-1 removed
25 unmodified lines26 return;27 }28 29 const [output] = await Promise.all([30- getStreamOutput({stream, onStreamEnd, fdNumber, encoding, buffer, maxBuffer, lines, allMixed, stripFinalNewline, verboseInfo, streamInfo}),30+ getStreamOutput({31+ stream,32+ onStreamEnd,33+ fdNumber,34+ encoding,35+ buffer,36+ maxBuffer,37+ lines,38+ allMixed,39+ stripFinalNewline,40+ verboseInfo,41+ streamInfo,42+ }),43 onStreamEnd,44 ]);45 return output;46 };modified:lib/resolve/wait-stream.js+2 added-2 removed
40 unmodified lines41 };42 43 const spyOnStdinDestroy = (subprocessStdin, subprocess, state) => {44 const {_destroy} = subprocessStdin;45- subprocessStdin._destroy = (...args) => {45+ subprocessStdin._destroy = (...destroyArguments) => {46 setStdinCleanedUp(subprocess, state);47- _destroy.call(subprocessStdin, ...args);47+ _destroy.call(subprocessStdin, ...destroyArguments);48 };49 };50 51 const setStdinCleanedUp = ({exitCode, signalCode}, state) => {45 unmodified linesmodified:lib/resolve/wait-subprocess.js+27 added-3 removed
19 unmodified lines20 originalStreams,21 controller,22 }) => {23 const exitPromise = waitForExit(subprocess);24- const streamInfo = {originalStreams, fileDescriptors, subprocess, exitPromise, propagating: false};24+ const streamInfo = {25+ originalStreams,26+ fileDescriptors,27+ subprocess,28+ exitPromise,29+ propagating: false,30+ };31 26- const stdioPromises = waitForStdioStreams({subprocess, encoding, buffer, maxBuffer, lines, stripFinalNewline, verboseInfo, streamInfo});27- const allPromise = waitForAllStream({subprocess, encoding, buffer, maxBuffer, lines, stripFinalNewline, verboseInfo, streamInfo});32+ const stdioPromises = waitForStdioStreams({33+ subprocess,34+ encoding,35+ buffer,36+ maxBuffer,37+ lines,38+ stripFinalNewline,39+ verboseInfo,40+ streamInfo,41+ });42+ const allPromise = waitForAllStream({43+ subprocess,44+ encoding,45+ buffer,46+ maxBuffer,47+ lines,48+ stripFinalNewline,49+ verboseInfo,50+ streamInfo,51+ });52 const originalPromises = waitForOriginalStreams(originalStreams, subprocess, streamInfo);53 const customStreamsEndPromises = waitForCustomStreamsEnd(fileDescriptors, streamInfo);54 55 try {51 unmodified linesmodified:lib/return/early-error.js+22 added-3 removed
1 import {ChildProcess} from 'node:child_process';2-import {PassThrough, Readable, Writable, Duplex} from 'node:stream';2+import {3+ PassThrough,4+ Readable,5+ Writable,6+ Duplex,7+} from 'node:stream';8 import {cleanupCustomStreams} from '../stdio/handle-async.js';9 import {makeEarlyError} from './result.js';10 import {handleResult} from './reject.js';11 5 unmodified lines17 const subprocess = new ChildProcess();18 createDummyStreams(subprocess, fileDescriptors);19 Object.assign(subprocess, {readable, writable, duplex});20 16- const earlyError = makeEarlyError({error, command, escapedCommand, fileDescriptors, options, startTime, isSync: false});21+ const earlyError = makeEarlyError({22+ error,23+ command,24+ escapedCommand,25+ fileDescriptors,26+ options,27+ startTime,28+ isSync: false,29+ });30 const promise = handleDummyPromise(earlyError, verboseInfo, options);31 return {subprocess, promise};32 };33 3 unmodified lines37 const stderr = createDummyStream();38 const extraStdio = Array.from({length: fileDescriptors.length - 3}, createDummyStream);39 const all = createDummyStream();40 const stdio = [stdin, stdout, stderr, ...extraStdio];28- Object.assign(subprocess, {stdin, stdout, stderr, all, stdio});41+ Object.assign(subprocess, {42+ stdin,43+ stdout,44+ stderr,45+ all,46+ stdio,47+ });48 };49 50 const createDummyStream = () => {51 const stream = new PassThrough();9 unmodified linesmodified:lib/return/message.js+12 added-1 removed
19 unmodified lines20 timeout,21 cwd,22 }) => {23 const errorCode = originalError?.code;24- const prefix = getErrorPrefix({originalError, timedOut, timeout, isMaxBuffer, maxBuffer, errorCode, signal, signalDescription, exitCode, isCanceled});24+ const prefix = getErrorPrefix({25+ originalError,26+ timedOut,27+ timeout,28+ isMaxBuffer,29+ maxBuffer,30+ errorCode,31+ signal,32+ signalDescription,33+ exitCode,34+ isCanceled,35+ });36 const originalMessage = getOriginalMessage(originalError, cwd);37 const newline = originalMessage === '' ? '' : '\n';38 const shortMessage = `${prefix}: ${escapedCommand}${newline}${originalMessage}`;39 const messageStdio = all === undefined ? [stdio[2], stdio[1]] : [all];61 unmodified linesmodified:lib/stdio/handle.js+26 added-5 removed
1 import {getStreamName} from '../utils/standard-stream.js';2 import {normalizeTransforms} from '../transform/normalize.js';3 import {getFdObjectMode} from '../transform/object-mode.js';4-import {getStdioItemType, isRegularUrl, isUnknownStdioString, FILE_TYPES} from './type.js';4+import {5+ getStdioItemType,6+ isRegularUrl,7+ isUnknownStdioString,8+ FILE_TYPES,9+} from './type.js';10 import {getStreamDirection} from './direction.js';11 import {normalizeStdioOption} from './stdio-option.js';12 import {handleNativeStream} from './native.js';13 import {handleInputOptions} from './input-option.js';14 15 // Handle `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, before spawning, in async/sync mode16 export const handleStdio = (addProperties, options, verboseInfo, isSync) => {17 const stdio = normalizeStdioOption(options, isSync);13- const fileDescriptors = stdio.map((stdioOption, fdNumber) =>14- getFileDescriptor({stdioOption, fdNumber, addProperties, options, isSync}));18+ const fileDescriptors = stdio.map((stdioOption, fdNumber) => getFileDescriptor({19+ stdioOption,20+ fdNumber,21+ addProperties,22+ options,23+ isSync,24+ }));25 options.stdio = fileDescriptors.map(({stdioItems}) => forwardStdio(stdioItems));26 return fileDescriptors;27 };28 1 unmodified line30 // This is what users would expect.31 // For example, `stdout: ['ignore']` behaves the same as `stdout: 'ignore'`.32 const getFileDescriptor = ({stdioOption, fdNumber, addProperties, options, isSync}) => {33 const optionName = getStreamName(fdNumber);24- const {stdioItems: initialStdioItems, isStdioArray} = initializeStdioItems({stdioOption, fdNumber, options, optionName});34+ const {stdioItems: initialStdioItems, isStdioArray} = initializeStdioItems({35+ stdioOption,36+ fdNumber,37+ options,38+ optionName,39+ });40 const direction = getStreamDirection(initialStdioItems, fdNumber, optionName);26- const stdioItems = initialStdioItems.map(stdioItem => handleNativeStream({stdioItem, isStdioArray, fdNumber, direction, isSync}));41+ const stdioItems = initialStdioItems.map(stdioItem => handleNativeStream({42+ stdioItem,43+ isStdioArray,44+ fdNumber,45+ direction,46+ isSync,47+ }));48 const normalizedStdioItems = normalizeTransforms(stdioItems, optionName, direction, options);49 const objectMode = getFdObjectMode(normalizedStdioItems, direction);50 validateFileObjectMode(normalizedStdioItems, objectMode);51 const finalStdioItems = normalizedStdioItems.map(stdioItem => addStreamProperties(stdioItem, addProperties, direction, options));96 unmodified linesmodified:lib/stdio/native.js+6 added-1 removed
21 unmodified lines22 : handleNativeStreamAsync({stdioItem, fdNumber});23 };24 25 const handleNativeStreamSync = ({stdioItem, stdioItem: {value, optionName}, fdNumber, direction}) => {26- const targetFd = getTargetFd({value, optionName, fdNumber, direction});26+ const targetFd = getTargetFd({27+ value,28+ optionName,29+ fdNumber,30+ direction,31+ });32 if (targetFd !== undefined) {33 return targetFd;34 }35 69 unmodified linesmodified:lib/terminate/kill.js+8 added-1 removed
23 unmodified lines24 export const subprocessKill = ({kill, subprocess, options: {forceKillAfterDelay, killSignal}, controller}, signalOrError, errorArgument) => {25 const {signal, error} = parseKillArguments(signalOrError, errorArgument, killSignal);26 emitKillError(subprocess, error);27 const killResult = kill(signal);28- setKillTimeout({kill, signal, forceKillAfterDelay, killSignal, killResult, controller});28+ setKillTimeout({29+ kill,30+ signal,31+ forceKillAfterDelay,32+ killSignal,33+ killResult,34+ controller,35+ });36 return killResult;37 };38 39 const parseKillArguments = (signalOrError, errorArgument, killSignal) => {44 unmodified linesmodified:lib/transform/generator.js+18 added-3 removed
1 unmodified line2 import {isAsyncGenerator} from '../stdio/type.js';3 import {getSplitLinesGenerator, getAppendNewlineGenerator} from './split.js';4 import {getValidateTransformInput, getValidateTransformReturn} from './validate.js';5 import {getEncodingTransformGenerator} from './encoding-transform.js';6-import {pushChunks, transformChunk, finalChunks, destroyTransform} from './run-async.js';7-import {pushChunksSync, transformChunkSync, finalChunksSync, runTransformSync} from './run-sync.js';6+import {7+ pushChunks,8+ transformChunk,9+ finalChunks,10+ destroyTransform,11+} from './run-async.js';12+import {13+ pushChunksSync,14+ transformChunkSync,15+ finalChunksSync,16+ runTransformSync,17+} from './run-sync.js';18 19 /*20 Generators can be used to transform/filter standard streams.21 72 unmodified lines94 getEncodingTransformGenerator(binary, encoding, writableObjectMode),95 getSplitLinesGenerator(binary, preserveNewlines, writableObjectMode, state),96 {transform, final},97 {transform: getValidateTransformReturn(readableObjectMode, optionName)},88- getAppendNewlineGenerator({binary, preserveNewlines, readableObjectMode, state}),98+ getAppendNewlineGenerator({99+ binary,100+ preserveNewlines,101+ readableObjectMode,102+ state,103+ }),104 ].filter(Boolean);105 };modified:lib/transform/normalize.js+32 added-4 removed
13 unmodified lines14 const transforms = stdioItems.filter(({type}) => TRANSFORM_TYPES.has(type));15 const newTransforms = Array.from({length: transforms.length});16 17 for (const [index, stdioItem] of Object.entries(transforms)) {18- newTransforms[index] = normalizeTransform({stdioItem, index: Number(index), newTransforms, optionName, direction, encoding});18+ newTransforms[index] = normalizeTransform({19+ stdioItem,20+ index: Number(index),21+ newTransforms,22+ optionName,23+ direction,24+ encoding,25+ });26 }27 28 return sortTransforms(newTransforms, direction);29 };3 unmodified lines33 return normalizeDuplex({stdioItem, optionName});34 }35 36 if (type === 'webTransform') {30- return normalizeTransformStream({stdioItem, index, newTransforms, direction});37+ return normalizeTransformStream({38+ stdioItem,39+ index,40+ newTransforms,41+ direction,42+ });43 }44 33- return normalizeGenerator({stdioItem, index, newTransforms, direction, encoding});45+ return normalizeGenerator({46+ stdioItem,47+ index,48+ newTransforms,49+ direction,50+ encoding,51+ });52 };53 54 const normalizeDuplex = ({55 stdioItem,38 unmodified lines94 objectMode,95 } = isPlainObj(value) ? value : {transform: value};96 const binary = binaryOption || BINARY_ENCODINGS.has(encoding);97 const {writableObjectMode, readableObjectMode} = getTransformObjectModes(objectMode, index, newTransforms, direction);80- return {...stdioItem, value: {transform, final, binary, preserveNewlines, writableObjectMode, readableObjectMode}};98+ return {99+ ...stdioItem,100+ value: {101+ transform,102+ final,103+ binary,104+ preserveNewlines,105+ writableObjectMode,106+ readableObjectMode,107+ },108+ };109 };110 111 const sortTransforms = (newTransforms, direction) => direction === 'input' ? newTransforms.reverse() : newTransforms;modified:lib/transform/run-async.js+2 added-2 removed
1 import {callbackify} from 'node:util';2 3-export const pushChunks = callbackify(async (getChunks, state, args, transformStream) => {4- state.currentIterable = getChunks(...args);3+export const pushChunks = callbackify(async (getChunks, state, getChunksArguments, transformStream) => {4+ state.currentIterable = getChunks(...getChunksArguments);5 6 try {7 for await (const chunk of state.currentIterable) {8 transformStream.push(chunk);51 unmodified linesmodified:lib/transform/run-sync.js+2 added-2 removed
1 // Duplicate the code from `transform-async.js` but as synchronous functions2-export const pushChunksSync = (getChunksSync, args, transformStream, done) => {2+export const pushChunksSync = (getChunksSync, getChunksArguments, transformStream, done) => {3 try {4- for (const chunk of getChunksSync(...args)) {4+ for (const chunk of getChunksSync(...getChunksArguments)) {5 transformStream.push(chunk);6 }7 8 done();42 unmodified linesmodified:lib/verbose/complete.js+14 added-2 removed
6 unmodified lines7 import {logError} from './error.js';8 9 // When `verbose` is `short|full`, print each command's completion, duration and error10 export const logFinalResult = ({shortMessage, failed, durationMs}, reject, verboseInfo) => {11- logResult({message: shortMessage, failed, reject, durationMs, verboseInfo});11+ logResult({12+ message: shortMessage,13+ failed,14+ reject,15+ durationMs,16+ verboseInfo,17+ });18 };19 20 // Same but for early validation errors21 export const logEarlyResult = (error, startTime, verboseInfo) => {11 unmodified lines33 return;34 }35 36 const icon = getIcon(failed, reject);31- logError({message, failed, reject, verboseId, icon});37+ logError({38+ message,39+ failed,40+ reject,41+ verboseId,42+ icon,43+ });44 logDuration(durationMs, verboseId, icon);45 };46 47 const logDuration = (durationMs, verboseId, icon) => {11 unmodified linesmodified:test/arguments/cwd.js+7 added-7 removed
3 unmodified lines4 import {pathToFileURL, fileURLToPath} from 'node:url';5 import tempfile from 'tempfile';6 import test from 'ava';7 import {execa, execaSync} from '../../index.js';8-import {FIXTURES_DIR, setFixtureDir} from '../helpers/fixtures-dir.js';8+import {FIXTURES_DIRECTORY, setFixtureDirectory} from '../helpers/fixtures-directory.js';9 10-setFixtureDir();10+setFixtureDirectory();11 12 const isWindows = process.platform === 'win32';13 14 const testOptionCwdString = async (t, execaMethod) => {55 unmodified lines70 }71 72 const cwdNotExisting = {cwd: 'does_not_exist', expectedCode: 'ENOENT', expectedMessage: 'The "cwd" option is invalid'};73 const cwdTooLong = {cwd: '.'.repeat(1e5), expectedCode: 'ENAMETOOLONG', expectedMessage: 'The "cwd" option is invalid'};74-const cwdNotDir = {cwd: fileURLToPath(import.meta.url), expectedCode: isWindows ? 'ENOENT' : 'ENOTDIR', expectedMessage: 'The "cwd" option is not a directory'};74+const cwdNotDirectory = {cwd: fileURLToPath(import.meta.url), expectedCode: isWindows ? 'ENOENT' : 'ENOTDIR', expectedMessage: 'The "cwd" option is not a directory'};75 76 const testCwdPostSpawn = async (t, {cwd, expectedCode, expectedMessage}, execaMethod) => {77 const {failed, code, message} = await execaMethod('empty.js', {cwd, reject: false});78 t.true(failed);5 unmodified lines84 test('The "cwd" option must be an existing file', testCwdPostSpawn, cwdNotExisting, execa);85 test('The "cwd" option must be an existing file - sync', testCwdPostSpawn, cwdNotExisting, execaSync);86 test('The "cwd" option must not be too long', testCwdPostSpawn, cwdTooLong, execa);87 test('The "cwd" option must not be too long - sync', testCwdPostSpawn, cwdTooLong, execaSync);88-test('The "cwd" option must be a directory', testCwdPostSpawn, cwdNotDir, execa);89-test('The "cwd" option must be a directory - sync', testCwdPostSpawn, cwdNotDir, execaSync);88+test('The "cwd" option must be a directory', testCwdPostSpawn, cwdNotDirectory, execa);89+test('The "cwd" option must be a directory - sync', testCwdPostSpawn, cwdNotDirectory, execaSync);90 91 const successProperties = {fixtureName: 'empty.js', expectedFailed: false};92 const errorProperties = {fixtureName: 'fail.js', expectedFailed: true};93 94 const testErrorCwd = async (t, execaMethod, {fixtureName, expectedFailed}) => {95- const {failed, cwd} = await execaMethod(fixtureName, {cwd: relative('.', FIXTURES_DIR), reject: false});95+ const {failed, cwd} = await execaMethod(fixtureName, {cwd: relative('.', FIXTURES_DIRECTORY), reject: false});96 t.is(failed, expectedFailed);97- t.is(cwd, FIXTURES_DIR);97+ t.is(cwd, FIXTURES_DIRECTORY);98 };99 100 test('result.cwd is defined', testErrorCwd, execa, successProperties);101 test('result.cwd is defined - sync', testErrorCwd, execaSync, successProperties);2 unmodified linesmodified:test/arguments/encoding-option.js+2 added-2 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 5-setFixtureDir();5+setFixtureDirectory();6 7 const testInvalidEncoding = (t, encoding, message, execaMethod) => {8 const error = t.throws(() => {9 execaMethod('empty.js', {encoding});30 unmodified linesmodified:test/arguments/env.js+2 added-2 removed
1 import process from 'node:process';2 import test from 'ava';3 import {execa} from '../../index.js';4-import {setFixtureDir, PATH_KEY} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory, PATH_KEY} from '../helpers/fixtures-directory.js';5 6-setFixtureDir();6+setFixtureDirectory();7 process.env.FOO = 'foo';8 9 const isWindows = process.platform === 'win32';10 22 unmodified linesmodified:test/arguments/escape.js+10 added-10 removed
1 import {platform} from 'node:process';2 import test from 'ava';3 import {execa, execaSync} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 6-setFixtureDir();6+setFixtureDirectory();7 8 const isWindows = platform === 'win32';9 10-const testResultCommand = async (t, expected, ...args) => {11- const {command: failCommand} = await t.throwsAsync(execa('fail.js', args));10+const testResultCommand = async (t, expected, ...commandArguments) => {11+ const {command: failCommand} = await t.throwsAsync(execa('fail.js', commandArguments));12 t.is(failCommand, `fail.js${expected}`);13 14- const {command} = await execa('noop.js', args);14+ const {command} = await execa('noop.js', commandArguments);15 t.is(command, `noop.js${expected}`);16 };17 18 testResultCommand.title = (message, expected) => `result.command is: ${JSON.stringify(expected)}`;1 unmodified line20 test(testResultCommand, ' foo bar', 'foo', 'bar');21 test(testResultCommand, ' baz quz', 'baz', 'quz');22 test(testResultCommand, '');23 24-const testEscapedCommand = async (t, args, expectedUnix, expectedWindows) => {24+const testEscapedCommand = async (t, commandArguments, expectedUnix, expectedWindows) => {25 const expected = isWindows ? expectedWindows : expectedUnix;26 27 t.like(28- await t.throwsAsync(execa('fail.js', args)),28+ await t.throwsAsync(execa('fail.js', commandArguments)),29 {escapedCommand: `fail.js ${expected}`},30 );31 32 t.like(t.throws(() => {33- execaSync('fail.js', args);33+ execaSync('fail.js', commandArguments);34 }), {escapedCommand: `fail.js ${expected}`});35 36 t.like(37- await execa('noop.js', args),37+ await execa('noop.js', commandArguments),38 {escapedCommand: `noop.js ${expected}`},39 );40 41 t.like(42- execaSync('noop.js', args),42+ execaSync('noop.js', commandArguments),43 {escapedCommand: `noop.js ${expected}`},44 );45 };46 54 unmodified linesmodified:test/arguments/fd-options.js+18 added-4 removed
1 unmodified line2 import {spawn} from 'node:child_process';3 import process from 'node:process';4 import test from 'ava';5 import {execa} from '../../index.js';6-import {setFixtureDir} from '../helpers/fixtures-dir.js';6+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';7 import {fullStdio, getStdio} from '../helpers/stdio.js';8 import {getEarlyErrorSubprocess} from '../helpers/early-error.js';9 import {assertPipeError} from '../helpers/pipe.js';10 11-setFixtureDir();11+setFixtureDirectory();12 13 const getMessage = message => Array.isArray(message)14 ? `"${message[0]}: ${message[1]}" option is incompatible`15 : message;20 unmodified lines36 from,37 to,38 writable = to !== undefined,39 }) => {40- assertNodeStream({t, message, getSource, from, to, methodName: writable ? 'writable' : 'readable'});41- assertNodeStream({t, message, getSource, from, to, methodName: 'duplex'});40+ assertNodeStream({41+ t,42+ message,43+ getSource,44+ from,45+ to,46+ methodName: writable ? 'writable' : 'readable',47+ });48+ assertNodeStream({49+ t,50+ message,51+ getSource,52+ from,53+ to,54+ methodName: 'duplex',55+ });56 };57 58 const assertNodeStream = ({t, message, getSource, from, to, methodName}) => {59 const error = t.throws(() => {680 unmodified linesmodified:test/arguments/local.js+14 added-14 removed
1 unmodified line2 import process from 'node:process';3 import {pathToFileURL} from 'node:url';4 import test from 'ava';5 import {execa, $} from '../../index.js';6-import {setFixtureDir, PATH_KEY} from '../helpers/fixtures-dir.js';6+import {setFixtureDirectory, PATH_KEY} from '../helpers/fixtures-directory.js';7 8-setFixtureDir();8+setFixtureDirectory();9 process.env.FOO = 'foo';10 11 const isWindows = process.platform === 'win32';12 const ENOENT_REGEXP = isWindows ? /failed with exit code 1/ : /spawn.* ENOENT/;13 14-const getPathWithoutLocalDir = () => {15- const newPath = process.env[PATH_KEY].split(delimiter).filter(pathDir => !BIN_DIR_REGEXP.test(pathDir)).join(delimiter);14+const getPathWithoutLocalDirectory = () => {15+ const newPath = process.env[PATH_KEY].split(delimiter).filter(pathDirectory => !BIN_DIR_REGEXP.test(pathDirectory)).join(delimiter);16 return {[PATH_KEY]: newPath};17 };18 19 const BIN_DIR_REGEXP = /node_modules[\\/]\.bin/;20 21-const pathWitoutLocalDir = getPathWithoutLocalDir();21+const pathWitoutLocalDirectory = getPathWithoutLocalDirectory();22 23 test('preferLocal: true', async t => {24- await t.notThrowsAsync(execa('ava', ['--version'], {preferLocal: true, env: pathWitoutLocalDir}));24+ await t.notThrowsAsync(execa('ava', ['--version'], {preferLocal: true, env: pathWitoutLocalDirectory}));25 });26 27 test('preferLocal: false', async t => {28- await t.throwsAsync(execa('ava', ['--version'], {preferLocal: false, env: pathWitoutLocalDir}), {message: ENOENT_REGEXP});28+ await t.throwsAsync(execa('ava', ['--version'], {preferLocal: false, env: pathWitoutLocalDirectory}), {message: ENOENT_REGEXP});29 });30 31 test('preferLocal: undefined', async t => {32- await t.throwsAsync(execa('ava', ['--version'], {env: pathWitoutLocalDir}), {message: ENOENT_REGEXP});32+ await t.throwsAsync(execa('ava', ['--version'], {env: pathWitoutLocalDirectory}), {message: ENOENT_REGEXP});33 });34 35 test('preferLocal: undefined with $', async t => {36- await t.notThrowsAsync($('ava', ['--version'], {env: pathWitoutLocalDir}));36+ await t.notThrowsAsync($('ava', ['--version'], {env: pathWitoutLocalDirectory}));37 });38 39 test('preferLocal: undefined with $.sync', t => {40- t.notThrows(() => $.sync('ava', ['--version'], {env: pathWitoutLocalDir}));40+ t.notThrows(() => $.sync('ava', ['--version'], {env: pathWitoutLocalDirectory}));41 });42 43 test('preferLocal: undefined with execa.pipe`...`', async t => {44- await t.throwsAsync(() => execa('node', ['--version']).pipe({env: pathWitoutLocalDir})`ava --version`);44+ await t.throwsAsync(() => execa('node', ['--version']).pipe({env: pathWitoutLocalDirectory})`ava --version`);45 });46 47 test('preferLocal: undefined with $.pipe`...`', async t => {48- await t.notThrows(() => $('node', ['--version']).pipe({env: pathWitoutLocalDir})`ava --version`);48+ await t.notThrows(() => $('node', ['--version']).pipe({env: pathWitoutLocalDirectory})`ava --version`);49 });50 51 test('preferLocal: undefined with execa.pipe()', async t => {52- await t.throwsAsync(() => execa('node', ['--version']).pipe('ava', ['--version'], {env: pathWitoutLocalDir}));52+ await t.throwsAsync(() => execa('node', ['--version']).pipe('ava', ['--version'], {env: pathWitoutLocalDirectory}));53 });54 55 test('preferLocal: undefined with $.pipe()', async t => {56- await t.notThrows(() => $('node', ['--version']).pipe('ava', ['--version'], {env: pathWitoutLocalDir}));56+ await t.notThrows(() => $('node', ['--version']).pipe('ava', ['--version'], {env: pathWitoutLocalDirectory}));57 });58 59 test('localDir option', async t => {60 const command = isWindows ? 'echo %PATH%' : 'echo $PATH';11 unmodified linesmodified:test/arguments/shell.js+2 added-2 removed
1 unmodified line2 import {pathToFileURL} from 'node:url';3 import test from 'ava';4 import which from 'which';5 import {execa} from '../../index.js';6-import {setFixtureDir} from '../helpers/fixtures-dir.js';6+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';7 import {identity} from '../helpers/stdio.js';8 9-setFixtureDir();9+setFixtureDirectory();10 process.env.FOO = 'foo';11 12 const isWindows = process.platform === 'win32';13 14 unmodified linesmodified:test/arguments/specific.js+2 added-2 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {foobarString} from '../helpers/input.js';5 6-setFixtureDir();6+setFixtureDirectory();7 8 // eslint-disable-next-line max-params9 const testPriorityOrder = async (t, buffer, bufferStdout, bufferStderr, execaMethod) => {10 const {stdout, stderr} = await execaMethod('noop-both.js', {buffer});28 unmodified linesmodified:test/convert/concurrent.js+2 added-2 removed
1 import {setTimeout} from 'node:timers/promises';2 import test from 'ava';3 import {execa} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {foobarString} from '../helpers/input.js';6 import {fullReadableStdio} from '../helpers/stdio.js';7 import {8 finishedStream,4 unmodified lines13 assertSubprocessError,14 getReadWriteSubprocess,15 } from '../helpers/convert.js';16 17-setFixtureDir();17+setFixtureDirectory();18 19 const endStream = async stream => {20 stream.end(foobarString);21 await setTimeout(0);351 unmodified linesmodified:test/convert/duplex.js+8 added-3 removed
1-import {compose, Readable, Writable, PassThrough} from 'node:stream';1+import {2+ compose,3+ Readable,4+ Writable,5+ PassThrough,6+} from 'node:stream';7 import {pipeline} from 'node:stream/promises';8 import {text} from 'node:stream/consumers';9 import test from 'ava';10 import {execa} from '../../index.js';6-import {setFixtureDir} from '../helpers/fixtures-dir.js';11+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';12 import {13 finishedStream,14 assertReadableAborted,15 assertWritableAborted,9 unmodified lines25 import {foobarString} from '../helpers/input.js';26 import {prematureClose, fullStdio, fullReadableStdio} from '../helpers/stdio.js';27 import {defaultHighWaterMark} from '../helpers/stream.js';28 24-setFixtureDir();29+setFixtureDirectory();30 31 test('.duplex() success', async t => {32 const subprocess = getReadWriteSubprocess();33 const stream = subprocess.duplex();160 unmodified linesmodified:test/convert/iterable.js+2 added-2 removed
1 import test from 'ava';2 import {execa} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {foobarString} from '../helpers/input.js';5 import {fullStdio, assertEpipe} from '../helpers/stdio.js';6 import {7 arrayFromAsync,2 unmodified lines10 assertProcessNormalExit,11 } from '../helpers/convert.js';12 import {simpleFull, noNewlinesChunks} from '../helpers/lines.js';13 14-setFixtureDir();14+setFixtureDirectory();15 16 const partialArrayFromAsync = async (asyncIterable, lines = []) => {17 // eslint-disable-next-line no-unreachable-loop18 for await (const line of asyncIterable) {136 unmodified linesmodified:test/convert/readable.js+8 added-3 removed
1 import {once} from 'node:events';2 import process from 'node:process';3-import {compose, Readable, Writable, PassThrough} from 'node:stream';3+import {4+ compose,5+ Readable,6+ Writable,7+ PassThrough,8+} from 'node:stream';9 import {pipeline} from 'node:stream/promises';10 import {text} from 'node:stream/consumers';11 import {setTimeout} from 'node:timers/promises';12 import test from 'ava';13 import {execa} from '../../index.js';9-import {setFixtureDir} from '../helpers/fixtures-dir.js';14+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';15 import {16 finishedStream,17 assertReadableAborted,18 assertWritableAborted,13 unmodified lines32 import {prematureClose, fullStdio} from '../helpers/stdio.js';33 import {outputObjectGenerator, getOutputsAsyncGenerator} from '../helpers/generator.js';34 import {defaultHighWaterMark, defaultObjectHighWaterMark} from '../helpers/stream.js';35 31-setFixtureDir();36+setFixtureDirectory();37 38 test('.readable() success', async t => {39 const subprocess = getReadableSubprocess();40 const stream = subprocess.readable();419 unmodified linesmodified:test/convert/shared.js+2 added-2 removed
1 import test from 'ava';2 import {execa} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {5 finishedStream,6 assertWritableAborted,7 assertStreamError,1 unmodified line9 getReadWriteSubprocess,10 } from '../helpers/convert.js';11 import {foobarString} from '../helpers/input.js';12 13-setFixtureDir();13+setFixtureDirectory();14 15 const testSubprocessFail = async (t, methodName) => {16 const subprocess = getReadWriteSubprocess();17 const stream = subprocess[methodName]();39 unmodified linesmodified:test/convert/writable.js+8 added-3 removed
4 unmodified lines5 import {setTimeout, scheduler} from 'node:timers/promises';6 import {promisify} from 'node:util';7 import test from 'ava';8 import {execa} from '../../index.js';9-import {setFixtureDir} from '../helpers/fixtures-dir.js';9+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';10 import {11 finishedStream,12 assertWritableAborted,13 assertProcessNormalExit,5 unmodified lines19 getWritableSubprocess,20 getReadableSubprocess,21 getReadWriteSubprocess,22 } from '../helpers/convert.js';23-import {foobarString, foobarBuffer, foobarObject, foobarObjectString} from '../helpers/input.js';23+import {24+ foobarString,25+ foobarBuffer,26+ foobarObject,27+ foobarObjectString,28+} from '../helpers/input.js';29 import {prematureClose, fullReadableStdio} from '../helpers/stdio.js';30 import {31 throwingGenerator,32 serializeGenerator,33 noopAsyncGenerator,34 } from '../helpers/generator.js';35 import {defaultHighWaterMark, defaultObjectHighWaterMark} from '../helpers/stream.js';36 32-setFixtureDir();37+setFixtureDirectory();38 39 test('.writable() success', async t => {40 const subprocess = getWritableSubprocess();41 const stream = subprocess.writable();353 unmodified linesmodified:test/fixtures/nested-double.js+5 added-5 removed
1 #!/usr/bin/env node2 import process from 'node:process';3 import {execa} from '../../index.js';4 5-const [options, file, ...args] = process.argv.slice(2);6-const firstArgs = args.slice(0, -1);7-const lastArg = args.at(-1);5+const [options, file, ...commandArguments] = process.argv.slice(2);6+const firstArguments = commandArguments.slice(0, -1);7+const lastArgument = commandArguments.at(-1);8 await Promise.all([9- execa(file, [...firstArgs, lastArg], JSON.parse(options)),10- execa(file, [...firstArgs, lastArg.toUpperCase()], JSON.parse(options)),9+ execa(file, [...firstArguments, lastArgument], JSON.parse(options)),10+ execa(file, [...firstArguments, lastArgument.toUpperCase()], JSON.parse(options)),11 ]);modified:test/fixtures/nested-fail.js+3 added-3 removed
1 #!/usr/bin/env node2 import process from 'node:process';3 import {execa} from '../../index.js';4 5-const [options, file, ...args] = process.argv.slice(2);6-const subprocess = execa(file, args, JSON.parse(options));7-subprocess.kill(new Error(args[0]));5+const [options, file, ...commandArguments] = process.argv.slice(2);6+const subprocess = execa(file, commandArguments, JSON.parse(options));7+subprocess.kill(new Error(commandArguments[0]));8 await subprocess;modified:test/fixtures/nested-file-url.js+2 added-2 removed
1 unmodified line2 import process from 'node:process';3 import {pathToFileURL} from 'node:url';4 import {execa} from '../../index.js';5 6-const [options, file, arg] = process.argv.slice(2);6+const [options, file, commandArgument] = process.argv.slice(2);7 const parsedOptions = JSON.parse(options);8-await execa(file, [arg], {...parsedOptions, stdout: pathToFileURL(parsedOptions.stdout)});8+await execa(file, [commandArgument], {...parsedOptions, stdout: pathToFileURL(parsedOptions.stdout)});modified:test/fixtures/nested-input.js+3 added-3 removed
1 unmodified line2 import process from 'node:process';3 import {execa, execaSync} from '../../index.js';4 import {foobarUtf16Uint8Array} from '../helpers/input.js';5 6-const [optionsString, file, isSync, ...args] = process.argv.slice(2);6+const [optionsString, file, isSync, ...commandArguments] = process.argv.slice(2);7 const options = {...JSON.parse(optionsString), input: foobarUtf16Uint8Array};8 if (isSync === 'true') {9- execaSync(file, args, options);9+ execaSync(file, commandArguments, options);10 } else {11- await execa(file, args, options);11+ await execa(file, commandArguments, options);12 }modified:test/fixtures/nested-node.js+3 added-3 removed
1 unmodified line2 import process from 'node:process';3 import {getWriteStream} from '../helpers/fs.js';4 import {execa, execaNode} from '../../index.js';5 6-const [fakeExecArgv, execaMethod, nodeOptions, file, ...args] = process.argv.slice(2);6+const [fakeExecArgv, execaMethod, nodeOptions, file, ...commandArguments] = process.argv.slice(2);7 8 if (fakeExecArgv !== '') {9 process.execArgv = [fakeExecArgv];10 }11 12 const filteredNodeOptions = [nodeOptions].filter(Boolean);13 const {stdout, stderr} = await (execaMethod === 'execaNode'14- ? execaNode(file, args, {nodeOptions: filteredNodeOptions})15- : execa(file, args, {nodeOptions: filteredNodeOptions, node: true}));14+ ? execaNode(file, commandArguments, {nodeOptions: filteredNodeOptions})15+ : execa(file, commandArguments, {nodeOptions: filteredNodeOptions, node: true}));16 console.log(stdout);17 getWriteStream(3).write(stderr);modified:test/fixtures/nested-pipe-file.js+10 added-3 removed
1 #!/usr/bin/env node2 import process from 'node:process';3 import {execa} from '../../index.js';4 5+const [6+ sourceOptions,7+ sourceFile,8+ sourceArgument,9+ destinationOptions,10+ destinationFile,11+ destinationArgument,5-const [sourceOptions, sourceFile, sourceArg, destinationOptions, destinationFile, destinationArg] = process.argv.slice(2);6-await execa(sourceFile, [sourceArg], JSON.parse(sourceOptions))7- .pipe(destinationFile, destinationArg === undefined ? [] : [destinationArg], JSON.parse(destinationOptions));12+] = process.argv.slice(2);13+await execa(sourceFile, [sourceArgument], JSON.parse(sourceOptions))14+ .pipe(destinationFile, destinationArgument === undefined ? [] : [destinationArgument], JSON.parse(destinationOptions));modified:test/fixtures/nested-pipe-script.js+10 added-3 removed
1 #!/usr/bin/env node2 import process from 'node:process';3 import {$} from '../../index.js';4 5+const [6+ sourceOptions,7+ sourceFile,8+ sourceArgument,9+ destinationOptions,10+ destinationFile,11+ destinationArgument,5-const [sourceOptions, sourceFile, sourceArg, destinationOptions, destinationFile, destinationArg] = process.argv.slice(2);6-await $(JSON.parse(sourceOptions))`${sourceFile} ${sourceArg}`7- .pipe(JSON.parse(destinationOptions))`${destinationFile} ${destinationArg === undefined ? [] : [destinationArg]}`;12+] = process.argv.slice(2);13+await $(JSON.parse(sourceOptions))`${sourceFile} ${sourceArgument}`14+ .pipe(JSON.parse(destinationOptions))`${destinationFile} ${destinationArgument === undefined ? [] : [destinationArgument]}`;modified:test/fixtures/nested-pipe-stream.js+2 added-2 removed
1 #!/usr/bin/env node2 import process from 'node:process';3 import {execa} from '../../index.js';4 5-const [options, file, arg, unpipe] = process.argv.slice(2);6-const subprocess = execa(file, [arg], JSON.parse(options));5+const [options, file, commandArgument, unpipe] = process.argv.slice(2);6+const subprocess = execa(file, [commandArgument], JSON.parse(options));7 subprocess.stdout.pipe(process.stdout);8 if (unpipe === 'true') {9 subprocess.stdout.unpipe(process.stdout);10 }2 unmodified linesmodified:test/fixtures/nested-pipe-subprocess.js+2 added-2 removed
1 #!/usr/bin/env node2 import process from 'node:process';3 import {execa} from '../../index.js';4 5-const [options, file, arg, unpipe] = process.argv.slice(2);6-const source = execa(file, [arg], JSON.parse(options));5+const [options, file, commandArgument, unpipe] = process.argv.slice(2);6+const source = execa(file, [commandArgument], JSON.parse(options));7 const destination = execa('stdin.js');8 const controller = new AbortController();9 const pipePromise = source.pipe(destination, {unpipeSignal: controller.signal});10 if (unpipe === 'true') {5 unmodified linesmodified:test/fixtures/nested-pipe-subprocesses.js+10 added-3 removed
1 #!/usr/bin/env node2 import process from 'node:process';3 import {execa} from '../../index.js';4 5+const [6+ sourceOptions,7+ sourceFile,8+ sourceArgument,9+ destinationOptions,10+ destinationFile,11+ destinationArgument,5-const [sourceOptions, sourceFile, sourceArg, destinationOptions, destinationFile, destinationArg] = process.argv.slice(2);6-await execa(sourceFile, [sourceArg], JSON.parse(sourceOptions))7- .pipe(execa(destinationFile, destinationArg === undefined ? [] : [destinationArg], JSON.parse(destinationOptions)));12+] = process.argv.slice(2);13+await execa(sourceFile, [sourceArgument], JSON.parse(sourceOptions))14+ .pipe(execa(destinationFile, destinationArgument === undefined ? [] : [destinationArgument], JSON.parse(destinationOptions)));modified:test/fixtures/nested-stdio.js+2 added-2 removed
1 unmodified line2 import process from 'node:process';3 import {execa, execaSync} from '../../index.js';4 import {parseStdioOption} from '../helpers/stdio.js';5 6-const [stdioOption, fdNumber, isSyncString, file, ...args] = process.argv.slice(2);6+const [stdioOption, fdNumber, isSyncString, file, ...commandArguments] = process.argv.slice(2);7 const optionValue = parseStdioOption(stdioOption);8 const isSync = isSyncString === 'true';9 const stdio = ['ignore', 'inherit', 'inherit'];10 stdio[fdNumber] = optionValue;11 const execaMethod = isSync ? execaSync : execa;12-const returnValue = execaMethod(file, [`${fdNumber}`, ...args], {stdio});12+const returnValue = execaMethod(file, [`${fdNumber}`, ...commandArguments], {stdio});13 14 const shouldPipe = Array.isArray(optionValue) && optionValue.includes('pipe');15 const fdReturnValue = returnValue.stdio[fdNumber];16 const hasPipe = fdReturnValue !== undefined && fdReturnValue !== null;12 unmodified linesmodified:test/fixtures/nested-sync-tty.js+4 added-4 removed
2 unmodified lines3 import tty from 'node:tty';4 import {execa, execaSync} from '../../index.js';5 6 const mockIsatty = fdNumber => {7- tty.isatty = fdNumberArg => fdNumber === fdNumberArg;7+ tty.isatty = fdNumberArgument => fdNumber === fdNumberArgument;8 };9 10 const originalIsatty = tty.isatty;11 const unmockIsatty = () => {12 tty.isatty = originalIsatty;13 };14 15-const [options, isSync, file, fdNumber, ...args] = process.argv.slice(2);15+const [options, isSync, file, fdNumber, ...commandArguments] = process.argv.slice(2);16 mockIsatty(Number(fdNumber));17 18 try {19 if (isSync === 'true') {20- execaSync(file, [fdNumber, ...args], JSON.parse(options));20+ execaSync(file, [fdNumber, ...commandArguments], JSON.parse(options));21 } else {22- await execa(file, [fdNumber, ...args], JSON.parse(options));22+ await execa(file, [fdNumber, ...commandArguments], JSON.parse(options));23 }24 } finally {25 unmockIsatty();26 }modified:test/fixtures/nested-sync.js+2 added-2 removed
1 #!/usr/bin/env node2 import process from 'node:process';3 import {execaSync} from '../../index.js';4 5-const [options, file, ...args] = process.argv.slice(2);5+const [options, file, ...commandArguments] = process.argv.slice(2);6 try {7- const result = execaSync(file, args, JSON.parse(options));7+ const result = execaSync(file, commandArguments, JSON.parse(options));8 process.send({result});9 } catch (error) {10 process.send({error});11 }modified:test/fixtures/nested-transform.js+3 added-3 removed
22 unmodified lines23 return getOutputGenerator(bigArray)(true);24 }25 };26 27-const [optionsString, file, ...args] = process.argv.slice(2);27+const [optionsString, file, ...commandArguments] = process.argv.slice(2);28 const {type, transformName, isSync, ...options} = JSON.parse(optionsString);29 const newOptions = {stdout: getTransform(type, transformName), ...options};30 if (isSync) {31- execaSync(file, args, newOptions);31+ execaSync(file, commandArguments, newOptions);32 } else {33- await execa(file, args, newOptions);33+ await execa(file, commandArguments, newOptions);34 }modified:test/fixtures/nested-writable-web.js+2 added-2 removed
1 #!/usr/bin/env node2 import process from 'node:process';3 import {execa} from '../../index.js';4 5-const [options, file, arg] = process.argv.slice(2);6-await execa(file, [arg], {...JSON.parse(options), stdout: new WritableStream()});5+const [options, file, commandArgument] = process.argv.slice(2);6+await execa(file, [commandArgument], {...JSON.parse(options), stdout: new WritableStream()});modified:test/fixtures/nested-writable.js+2 added-2 removed
1 #!/usr/bin/env node2 import process from 'node:process';3 import {execa} from '../../index.js';4 5-const [options, file, arg] = process.argv.slice(2);6-await execa(file, [arg], {...JSON.parse(options), stdout: process.stdout});5+const [options, file, commandArgument] = process.argv.slice(2);6+await execa(file, [commandArgument], {...JSON.parse(options), stdout: process.stdout});modified:test/fixtures/nested.js+2 added-2 removed
1 #!/usr/bin/env node2 import process from 'node:process';3 import {execa} from '../../index.js';4 5-const [options, file, ...args] = process.argv.slice(2);5+const [options, file, ...commandArguments] = process.argv.slice(2);6 try {7- const result = await execa(file, args, JSON.parse(options));7+ const result = await execa(file, commandArguments, JSON.parse(options));8 process.send({result});9 } catch (error) {10 process.send({error});11 }modified:test/fixtures/no-await.js+2 added-2 removed
1 unmodified line2 import process from 'node:process';3 import {once} from 'node:events';4 import {execa} from '../../index.js';5 6-const [options, file, ...args] = process.argv.slice(2);7-execa(file, args, JSON.parse(options));6+const [options, file, ...commandArguments] = process.argv.slice(2);7+execa(file, commandArguments, JSON.parse(options));8 const [error] = await once(process, 'unhandledRejection');9 console.log(error.shortMessage);modified:test/fixtures/stdin-script.js+2 added-2 removed
1 #!/usr/bin/env node2 import {$} from '../../index.js';3-import {FIXTURES_DIR} from '../helpers/fixtures-dir.js';3+import {FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';4 5-await $({stdout: 'inherit'})`node ${`${FIXTURES_DIR}/stdin.js`}`;5+await $({stdout: 'inherit'})`node ${`${FIXTURES_DIRECTORY}/stdin.js`}`;modified:test/fixtures/worker.js+4 added-4 removed
1 import {once} from 'node:events';2 import {workerData, parentPort} from 'node:worker_threads';3 import {execa} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 6-setFixtureDir();6+setFixtureDirectory();7 8-const {nodeFile, args, options} = workerData;8+const {nodeFile, commandArguments, options} = workerData;9 try {10- const subprocess = execa(nodeFile, args, options);10+ const subprocess = execa(nodeFile, commandArguments, options);11 const [parentResult, [{result, error}]] = await Promise.all([subprocess, once(subprocess, 'message')]);12 parentPort.postMessage({parentResult, result, error});13 } catch (parentError) {14 parentPort.postMessage({parentError});1 unmodified linedeleted:test/helpers/fixtures-dir.js-15 removed
1-import {delimiter, resolve} from 'node:path';2-import process from 'node:process';3-import {fileURLToPath} from 'node:url';4-import pathKey from 'path-key';5-6-export const PATH_KEY = pathKey();7-export const FIXTURES_DIR_URL = new URL('../fixtures/', import.meta.url);8-export const FIXTURES_DIR = resolve(fileURLToPath(FIXTURES_DIR_URL));9-10-// Add the fixtures directory to PATH so fixtures can be executed without adding11-// `node`. This is only meant to make writing tests simpler.12-export const setFixtureDir = () => {13- process.env[PATH_KEY] = FIXTURES_DIR + delimiter + process.env[PATH_KEY];14-};15-added:test/helpers/fixtures-directory.js+15 added
1+import {delimiter, resolve} from 'node:path';2+import process from 'node:process';3+import {fileURLToPath} from 'node:url';4+import pathKey from 'path-key';5+6+export const PATH_KEY = pathKey();7+export const FIXTURES_DIRECTORY_URL = new URL('../fixtures/', import.meta.url);8+export const FIXTURES_DIRECTORY = resolve(fileURLToPath(FIXTURES_DIRECTORY_URL));9+10+// Add the fixtures directory to PATH so fixtures can be executed without adding11+// `node`. This is only meant to make writing tests simpler.12+export const setFixtureDirectory = () => {13+ process.env[PATH_KEY] = FIXTURES_DIRECTORY + delimiter + process.env[PATH_KEY];14+};15+modified:test/helpers/generator.js+6 added-1 removed
1-import {setImmediate, setInterval, setTimeout, scheduler} from 'node:timers/promises';1+import {2+ setImmediate,3+ setInterval,4+ setTimeout,5+ scheduler,6+} from 'node:timers/promises';7 import {foobarObject, foobarString} from './input.js';8 9 const getGenerator = transform => (objectMode, binary, preserveNewlines) => ({10 transform,108 unmodified linesmodified:test/helpers/nested.js+20 added-16 removed
1 import {once} from 'node:events';2 import {Worker} from 'node:worker_threads';3 import {execa} from '../../index.js';4-import {FIXTURES_DIR_URL} from './fixtures-dir.js';4+import {FIXTURES_DIRECTORY_URL} from './fixtures-directory.js';5 6-const WORKER_URL = new URL('worker.js', FIXTURES_DIR_URL);6+const WORKER_URL = new URL('worker.js', FIXTURES_DIRECTORY_URL);7 8-const runWorker = (nodeFile, args, options) => {9- [args, options] = Array.isArray(args) ? [args, options] : [[], args];10- return new Worker(WORKER_URL, {workerData: {nodeFile, args, options}});8+const runWorker = (nodeFile, commandArguments, options) => {9+ [commandArguments, options] = Array.isArray(commandArguments)10+ ? [commandArguments, options]11+ : [[], commandArguments];12+ return new Worker(WORKER_URL, {workerData: {nodeFile, commandArguments, options}});13 };14 15 // eslint-disable-next-line max-params14-const nestedCall = (isWorker, fixtureName, execaMethod, file, args, options, parentOptions) => {15- [args, options = {}, parentOptions = {}] = Array.isArray(args) ? [args, options, parentOptions] : [[], args, options];16- const subprocessOrWorker = execaMethod(fixtureName, [JSON.stringify(options), file, ...args], {...parentOptions, ipc: true});16+const nestedCall = (isWorker, fixtureName, execaMethod, file, commandArguments, options, parentOptions) => {17+ [commandArguments, options = {}, parentOptions = {}] = Array.isArray(commandArguments)18+ ? [commandArguments, options, parentOptions]19+ : [[], commandArguments, options];20+ const subprocessOrWorker = execaMethod(fixtureName, [JSON.stringify(options), file, ...commandArguments], {...parentOptions, ipc: true});21 const onMessage = once(subprocessOrWorker, 'message');22 const promise = getNestedResult(onMessage);23 promise.parent = isWorker ? getParentResult(onMessage) : subprocessOrWorker;24 return promise;17 unmodified lines42 43 return {result, parentResult};44 };45 42-export const nestedWorker = (...args) => nestedCall(true, 'nested.js', runWorker, ...args);43-const nestedExeca = (fixtureName, ...args) => nestedCall(false, fixtureName, execa, ...args);44-export const nestedExecaAsync = (...args) => nestedExeca('nested.js', ...args);45-export const nestedExecaSync = (...args) => nestedExeca('nested-sync.js', ...args);46-export const parentWorker = (...args) => nestedWorker(...args).parent;47-export const parentExeca = (...args) => nestedExeca(...args).parent;48-export const parentExecaAsync = (...args) => nestedExecaAsync(...args).parent;49-export const parentExecaSync = (...args) => nestedExecaSync(...args).parent;46+export const nestedWorker = (...commandArguments) => nestedCall(true, 'nested.js', runWorker, ...commandArguments);47+const nestedExeca = (fixtureName, ...commandArguments) => nestedCall(false, fixtureName, execa, ...commandArguments);48+export const nestedExecaAsync = (...commandArguments) => nestedExeca('nested.js', ...commandArguments);49+export const nestedExecaSync = (...commandArguments) => nestedExeca('nested-sync.js', ...commandArguments);50+export const parentWorker = (...commandArguments) => nestedWorker(...commandArguments).parent;51+export const parentExeca = (...commandArguments) => nestedExeca(...commandArguments).parent;52+export const parentExecaAsync = (...commandArguments) => nestedExecaAsync(...commandArguments).parent;53+export const parentExecaSync = (...commandArguments) => nestedExecaSync(...commandArguments).parent;modified:test/helpers/stream.js+6 added-1 removed
1-import {Readable, Writable, PassThrough, getDefaultHighWaterMark} from 'node:stream';1+import {2+ Readable,3+ Writable,4+ PassThrough,5+ getDefaultHighWaterMark,6+} from 'node:stream';7 import {foobarString} from './input.js';8 9 export const noopReadable = () => new Readable({read() {}});10 export const noopWritable = () => new Writable({write() {}});5 unmodified linesmodified:test/io/input-option.js+15 added-4 removed
1 import {Writable} from 'node:stream';2 import test from 'ava';3 import {execa, execaSync} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';5-import {runExeca, runExecaSync, runScript, runScriptSync} from '../helpers/run.js';6-import {foobarUint8Array, foobarBuffer, foobarArrayBuffer, foobarUint16Array, foobarDataView} from '../helpers/input.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5+import {6+ runExeca,7+ runExecaSync,8+ runScript,9+ runScriptSync,10+} from '../helpers/run.js';11+import {12+ foobarUint8Array,13+ foobarBuffer,14+ foobarArrayBuffer,15+ foobarUint16Array,16+ foobarDataView,17+} from '../helpers/input.js';18 8-setFixtureDir();19+setFixtureDirectory();20 21 const testInput = async (t, input, execaMethod) => {22 const {stdout} = await execaMethod('stdin.js', {input});23 t.is(stdout, 'foobar');31 unmodified linesmodified:test/io/input-sync.js+2 added-2 removed
1 import test from 'ava';2 import {execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {getStdio} from '../helpers/stdio.js';5 6-setFixtureDir();6+setFixtureDirectory();7 8 const getFd3InputMessage = type => `not \`stdio[3]\`, can be ${type}`;9 10 const testFd3InputSync = (t, stdioOption, expectedMessage) => {8 unmodified linesmodified:test/io/iterate.js+8 added-3 removed
1 import {once} from 'node:events';2 import {getDefaultHighWaterMark} from 'node:stream';3 import test from 'ava';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {6 assertStreamOutput,7 assertIterableChunks,8 assertStreamChunks,20 unmodified lines29 complexChunksEnd,30 } from '../helpers/lines.js';31 import {outputObjectGenerator, getOutputGenerator} from '../helpers/generator.js';32 import {foobarString, foobarObject} from '../helpers/input.js';33-import {multibyteChar, multibyteUint8Array, breakingLength, brokenSymbol} from '../helpers/encoding.js';33+import {34+ multibyteChar,35+ multibyteUint8Array,36+ breakingLength,37+ brokenSymbol,38+} from '../helpers/encoding.js';39 35-setFixtureDir();40+setFixtureDirectory();41 42 const foobarObjectChunks = [foobarObject, foobarObject, foobarObject];43 44 const getSubprocess = (methodName, output, options) => {162 unmodified linesmodified:test/io/max-buffer.js+8 added-3 removed
1 import {Buffer} from 'node:buffer';2 import test from 'ava';3 import getStream from 'get-stream';4 import {execa, execaSync} from '../../index.js';5-import {setFixtureDir} from '../helpers/fixtures-dir.js';5+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6 import {fullStdio} from '../helpers/stdio.js';7 import {getEarlyErrorSubprocess, getEarlyErrorSubprocessSync} from '../helpers/early-error.js';8 import {maxBuffer, assertErrorMessage} from '../helpers/max-buffer.js';9 10-setFixtureDir();10+setFixtureDirectory();11 12 const maxBufferMessage = {message: /maxBuffer exceeded/};13 const maxBufferCodeSync = {code: 'ENOBUFS'};14 126 unmodified lines141 const maxBufferStderr = 4 - difference;142 const {isMaxBuffer, shortMessage, stdout, stderr, all} = await execa(143 'noop-both.js',144 ['\n'.repeat(maxBufferStdout - 1), '\n'.repeat(maxBufferStderr - difference)],145- {maxBuffer: {stdout: maxBufferStdout, stderr: maxBufferStderr}, all: true, stripFinalNewline: false, reject: false},145+ {146+ maxBuffer: {stdout: maxBufferStdout, stderr: maxBufferStderr},147+ all: true,148+ stripFinalNewline: false,149+ reject: false,150+ },151 );152 t.is(isMaxBuffer, shouldFail);153 if (shouldFail) {154 assertErrorMessage(t, shortMessage, {fdNumber: 2, length: maxBufferStderr});116 unmodified linesmodified:test/io/output-async.js+2 added-2 removed
3 unmodified lines4 import test from 'ava';5 import {execa} from '../../index.js';6 import {STANDARD_STREAMS} from '../helpers/stdio.js';7 import {foobarString} from '../helpers/input.js';8-import {setFixtureDir} from '../helpers/fixtures-dir.js';8+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';9 import {assertMaxListeners} from '../helpers/listeners.js';10 11-setFixtureDir();11+setFixtureDirectory();12 13 const getStandardStreamListeners = stream => Object.fromEntries(stream.eventNames().map(eventName => [eventName, stream.listeners(eventName)]));14 const getStandardStreamsListeners = () => STANDARD_STREAMS.map(stream => getStandardStreamListeners(stream));15 69 unmodified linesmodified:test/io/output-sync.js+2 added-2 removed
1 import test from 'ava';2 import {execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {throwingGenerator} from '../helpers/generator.js';5 import {foobarString} from '../helpers/input.js';6 7-setFixtureDir();7+setFixtureDirectory();8 9 test('Handles errors with stdout generator, sync', t => {10 const cause = new Error(foobarString);11 const error = t.throws(() => {22 unmodified linesmodified:test/io/pipeline.js+2 added-2 removed
1 import test from 'ava';2 import {execa} from '../../index.js';3 import {getStdio, STANDARD_STREAMS} from '../helpers/stdio.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 6-setFixtureDir();6+setFixtureDirectory();7 8 const testDestroyStandard = async (t, fdNumber) => {9 const subprocess = execa('forever.js', {...getStdio(fdNumber, [STANDARD_STREAMS[fdNumber], 'pipe']), timeout: 1});10 await t.throwsAsync(subprocess, {message: /timed out/});28 unmodified linesmodified:test/io/strip-newline.js+2 added-2 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {fullStdio} from '../helpers/stdio.js';5 import {noopGenerator} from '../helpers/generator.js';6 import {foobarString} from '../helpers/input.js';7 8-setFixtureDir();8+setFixtureDirectory();9 10 // eslint-disable-next-line max-params11 const testStripFinalNewline = async (t, fdNumber, stripFinalNewline, shouldStrip, execaMethod) => {12 const {stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`, `${foobarString}\n`], {...fullStdio, stripFinalNewline});44 unmodified linesmodified:test/methods/command.js+9 added-9 removed
1 import {join} from 'node:path';2 import test from 'ava';3 import {execaCommand, execaCommandSync} from '../../index.js';4-import {setFixtureDir, FIXTURES_DIR} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';5 import {QUOTE} from '../helpers/verbose.js';6 7-setFixtureDir();8-const STDIN_FIXTURE = join(FIXTURES_DIR, 'stdin.js');7+setFixtureDirectory();8+const STDIN_FIXTURE = join(FIXTURES_DIRECTORY, 'stdin.js');9 10 test('execaCommand()', async t => {11 const {stdout} = await execaCommand('echo.js foo bar');12 t.is(stdout, 'foo\nbar');78 unmodified lines91 const {stdout} = await execaCommand(' echo.js foo bar ');92 t.is(stdout, 'foo\nbar');93 });94 95-const testInvalidArgsArray = (t, execaMethod) => {95+const testInvalidArgumentsArray = (t, execaMethod) => {96 t.throws(() => {97 execaMethod('echo', ['foo']);98 }, {message: /The command and its arguments must be passed as a single string/});99 };100 101-test('execaCommand() must not pass an array of arguments', testInvalidArgsArray, execaCommand);102-test('execaCommandSync() must not pass an array of arguments', testInvalidArgsArray, execaCommandSync);101+test('execaCommand() must not pass an array of arguments', testInvalidArgumentsArray, execaCommand);102+test('execaCommandSync() must not pass an array of arguments', testInvalidArgumentsArray, execaCommandSync);103 104-const testInvalidArgsTemplate = (t, execaMethod) => {104+const testInvalidArgumentsTemplate = (t, execaMethod) => {105 t.throws(() => {106 // eslint-disable-next-line no-unused-expressions107 execaMethod`echo foo`;108 }, {message: /The command and its arguments must be passed as a single string/});109 };110 111-test('execaCommand() must not pass an array of arguments with a template string', testInvalidArgsTemplate, execaCommand);112-test('execaCommandSync() must not pass an array of arguments with a template string', testInvalidArgsTemplate, execaCommandSync);111+test('execaCommand() must not pass an array of arguments with a template string', testInvalidArgumentsTemplate, execaCommand);112+test('execaCommandSync() must not pass an array of arguments with a template string', testInvalidArgumentsTemplate, execaCommandSync);modified:test/methods/create-bind.js+10 added-5 removed
1 import {join} from 'node:path';2 import test from 'ava';3-import {execa, execaSync, execaNode, $} from '../../index.js';3+import {4+ execa,5+ execaSync,6+ execaNode,7+ $,8+} from '../../index.js';9 import {foobarString, foobarUppercase} from '../helpers/input.js';10 import {uppercaseGenerator} from '../helpers/generator.js';6-import {setFixtureDir, FIXTURES_DIR} from '../helpers/fixtures-dir.js';11+import {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';12 8-setFixtureDir();13+setFixtureDirectory();14 10-const NOOP_PATH = join(FIXTURES_DIR, 'noop.js');11-const PRINT_ENV_PATH = join(FIXTURES_DIR, 'environment.js');15+const NOOP_PATH = join(FIXTURES_DIRECTORY, 'noop.js');16+const PRINT_ENV_PATH = join(FIXTURES_DIRECTORY, 'environment.js');17 18 const testBindOptions = async (t, execaMethod) => {19 const {stdout} = await execaMethod({stripFinalNewline: false})(NOOP_PATH, [foobarString]);20 t.is(stdout, `${foobarString}\n`);89 unmodified linesmodified:test/methods/create-main.js+12 added-7 removed
1 import {join} from 'node:path';2 import test from 'ava';3-import {execa, execaSync, execaNode, $} from '../../index.js';3+import {4+ execa,5+ execaSync,6+ execaNode,7+ $,8+} from '../../index.js';9 import {foobarString, foobarArray} from '../helpers/input.js';5-import {setFixtureDir, FIXTURES_DIR} from '../helpers/fixtures-dir.js';10+import {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';11 7-setFixtureDir();12+setFixtureDirectory();13 9-const NOOP_PATH = join(FIXTURES_DIR, 'noop.js');14+const NOOP_PATH = join(FIXTURES_DIRECTORY, 'noop.js');15 16 const testTemplate = async (t, execaMethod) => {17 const {stdout} = await execaMethod`${NOOP_PATH} ${foobarString}`;18 t.is(stdout, foobarString);27 unmodified lines46 47 test('execaSync() can use template strings with options', testTemplateOptionsSync, execaSync);48 test('$.sync can use template strings with options', testTemplateOptionsSync, $.sync);49 45-const testSpacedCommand = async (t, args, execaMethod) => {46- const {stdout} = await execaMethod('command with space.js', args);47- const expectedStdout = args === undefined ? '' : args.join('\n');50+const testSpacedCommand = async (t, commandArguments, execaMethod) => {51+ const {stdout} = await execaMethod('command with space.js', commandArguments);52+ const expectedStdout = commandArguments === undefined ? '' : commandArguments.join('\n');53 t.is(stdout, expectedStdout);54 };55 56 test('allow commands with spaces and no array arguments', testSpacedCommand, undefined, execa);7 unmodified linesmodified:test/methods/main-async.js+2 added-2 removed
1 import process from 'node:process';2 import test from 'ava';3 import {execa} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 6-setFixtureDir();6+setFixtureDirectory();7 8 const isWindows = process.platform === 'win32';9 10 if (isWindows) {16 unmodified linesmodified:test/methods/node.js+7 added-7 removed
4 unmodified lines5 import test from 'ava';6 import getNode from 'get-node';7 import {pEvent} from 'p-event';8 import {execa, execaSync, execaNode} from '../../index.js';9-import {FIXTURES_DIR} from '../helpers/fixtures-dir.js';9+import {FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';10 import {identity, fullStdio} from '../helpers/stdio.js';11 import {foobarString} from '../helpers/input.js';12 13-process.chdir(FIXTURES_DIR);13+process.chdir(FIXTURES_DIRECTORY);14 15-const runWithNodeOption = (file, args, options) => Array.isArray(args)16- ? execa(file, args, {...options, node: true})15+const runWithNodeOption = (file, commandArguments, options) => Array.isArray(commandArguments)16+ ? execa(file, commandArguments, {...options, node: true})17 : execa(file, {...options, node: true});18-const runWithNodeOptionSync = (file, args, options) => Array.isArray(args)19- ? execaSync(file, args, {...options, node: true})18+const runWithNodeOptionSync = (file, commandArguments, options) => Array.isArray(commandArguments)19+ ? execaSync(file, commandArguments, {...options, node: true})20 : execaSync(file, {...options, node: true});21 const runWithIpc = (file, options) => execa('node', [file], {...options, ipc: true});22 23 const testNodeSuccess = async (t, execaMethod) => {163 unmodified lines187 188 const spawnNestedExecaNode = (realExecArgv, fakeExecArgv, execaMethod, nodeOptions) => execa(189 'node',190 [...realExecArgv, 'nested-node.js', fakeExecArgv, execaMethod, nodeOptions, 'noop.js', foobarString],191- {...fullStdio, cwd: FIXTURES_DIR},191+ {...fullStdio, cwd: FIXTURES_DIRECTORY},192 );193 194 const testInspectRemoval = async (t, fakeExecArgv, execaMethod) => {195 const {stdout, stdio} = await spawnNestedExecaNode([], fakeExecArgv, execaMethod, '');110 unmodified linesmodified:test/methods/override-promise.js+2 added-2 removed
1 import test from 'ava';2 // The helper module overrides Promise on import so has to be imported before `execa`.3 import {restorePromise} from '../helpers/override-promise.js';4 import {execa} from '../../index.js';5-import {setFixtureDir} from '../helpers/fixtures-dir.js';5+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6 7 restorePromise();8-setFixtureDir();8+setFixtureDirectory();9 10 test('should work with third-party Promise', async t => {11 const {stdout} = await execa('noop.js', ['foo']);12 t.is(stdout, 'foo');1 unmodified linemodified:test/methods/parameters-args.js+34 added-27 removed
1 import test from 'ava';2-import {execa, execaSync, execaCommand, execaCommandSync, execaNode, $} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';2+import {3+ execa,4+ execaSync,5+ execaCommand,6+ execaCommandSync,7+ execaNode,8+ $,9+} from '../../index.js';10+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';11 5-setFixtureDir();12+setFixtureDirectory();13 7-const testInvalidArgs = async (t, execaMethod) => {14+const testInvalidArguments = async (t, execaMethod) => {15 t.throws(() => {16 execaMethod('echo', true);17 }, {message: /Second argument must be either/});18 };19 13-test('execa()\'s second argument must be valid', testInvalidArgs, execa);14-test('execaSync()\'s second argument must be valid', testInvalidArgs, execaSync);15-test('execaCommand()\'s second argument must be valid', testInvalidArgs, execaCommand);16-test('execaCommandSync()\'s second argument must be valid', testInvalidArgs, execaCommandSync);17-test('execaNode()\'s second argument must be valid', testInvalidArgs, execaNode);18-test('$\'s second argument must be valid', testInvalidArgs, $);19-test('$.sync\'s second argument must be valid', testInvalidArgs, $.sync);20+test('execa()\'s second argument must be valid', testInvalidArguments, execa);21+test('execaSync()\'s second argument must be valid', testInvalidArguments, execaSync);22+test('execaCommand()\'s second argument must be valid', testInvalidArguments, execaCommand);23+test('execaCommandSync()\'s second argument must be valid', testInvalidArguments, execaCommandSync);24+test('execaNode()\'s second argument must be valid', testInvalidArguments, execaNode);25+test('$\'s second argument must be valid', testInvalidArguments, $);26+test('$.sync\'s second argument must be valid', testInvalidArguments, $.sync);27 21-const testInvalidArgsItems = async (t, execaMethod) => {28+const testInvalidArgumentsItems = async (t, execaMethod) => {29 t.throws(() => {30 execaMethod('echo', [{}]);31 }, {message: 'Second argument must be an array of strings: [object Object]'});32 };33 27-test('execa()\'s second argument must not be objects', testInvalidArgsItems, execa);28-test('execaSync()\'s second argument must not be objects', testInvalidArgsItems, execaSync);29-test('execaCommand()\'s second argument must not be objects', testInvalidArgsItems, execaCommand);30-test('execaCommandSync()\'s second argument must not be objects', testInvalidArgsItems, execaCommandSync);31-test('execaNode()\'s second argument must not be objects', testInvalidArgsItems, execaNode);32-test('$\'s second argument must not be objects', testInvalidArgsItems, $);33-test('$.sync\'s second argument must not be objects', testInvalidArgsItems, $.sync);34+test('execa()\'s second argument must not be objects', testInvalidArgumentsItems, execa);35+test('execaSync()\'s second argument must not be objects', testInvalidArgumentsItems, execaSync);36+test('execaCommand()\'s second argument must not be objects', testInvalidArgumentsItems, execaCommand);37+test('execaCommandSync()\'s second argument must not be objects', testInvalidArgumentsItems, execaCommandSync);38+test('execaNode()\'s second argument must not be objects', testInvalidArgumentsItems, execaNode);39+test('$\'s second argument must not be objects', testInvalidArgumentsItems, $);40+test('$.sync\'s second argument must not be objects', testInvalidArgumentsItems, $.sync);41 35-const testNullByteArg = async (t, execaMethod) => {42+const testNullByteArgument = async (t, execaMethod) => {43 t.throws(() => {44 execaMethod('echo', ['a\0b']);45 }, {message: /null bytes/});46 };47 41-test('execa()\'s second argument must not include \\0', testNullByteArg, execa);42-test('execaSync()\'s second argument must not include \\0', testNullByteArg, execaSync);43-test('execaCommand()\'s second argument must not include \\0', testNullByteArg, execaCommand);44-test('execaCommandSync()\'s second argument must not include \\0', testNullByteArg, execaCommandSync);45-test('execaNode()\'s second argument must not include \\0', testNullByteArg, execaNode);46-test('$\'s second argument must not include \\0', testNullByteArg, $);47-test('$.sync\'s second argument must not include \\0', testNullByteArg, $.sync);48+test('execa()\'s second argument must not include \\0', testNullByteArgument, execa);49+test('execaSync()\'s second argument must not include \\0', testNullByteArgument, execaSync);50+test('execaCommand()\'s second argument must not include \\0', testNullByteArgument, execaCommand);51+test('execaCommandSync()\'s second argument must not include \\0', testNullByteArgument, execaCommandSync);52+test('execaNode()\'s second argument must not include \\0', testNullByteArgument, execaNode);53+test('$\'s second argument must not include \\0', testNullByteArgument, $);54+test('$.sync\'s second argument must not include \\0', testNullByteArgument, $.sync);modified:test/methods/parameters-command.js+16 added-9 removed
1 import {join, basename} from 'node:path';2 import {fileURLToPath} from 'node:url';3 import test from 'ava';4-import {execa, execaSync, execaCommand, execaCommandSync, execaNode, $} from '../../index.js';5-import {setFixtureDir, FIXTURES_DIR_URL} from '../helpers/fixtures-dir.js';4+import {5+ execa,6+ execaSync,7+ execaCommand,8+ execaCommandSync,9+ execaNode,10+ $,11+} from '../../index.js';12+import {setFixtureDirectory, FIXTURES_DIRECTORY_URL} from '../helpers/fixtures-directory.js';13 import {foobarString} from '../helpers/input.js';14 8-setFixtureDir();15+setFixtureDirectory();16 17 const testFileUrl = async (t, execaMethod) => {11- const command = new URL('noop.js', FIXTURES_DIR_URL);18+ const command = new URL('noop.js', FIXTURES_DIRECTORY_URL);19 const {stdout} = await execaMethod(command);20 t.is(stdout, foobarString);21 };22 19 unmodified lines42 test('execaNode()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaNode);43 test('$\'s command argument cannot be a non-file URL', testInvalidFileUrl, $);44 test('$.sync\'s command argument cannot be a non-file URL', testInvalidFileUrl, $.sync);45 39-const testInvalidCommand = async (t, arg, execaMethod) => {46+const testInvalidCommand = async (t, commandArgument, execaMethod) => {47 t.throws(() => {41- execaMethod(arg);48+ execaMethod(commandArgument);49 }, {message: /First argument must be a string or a file URL/});50 };51 52 test('execa()\'s first argument must be defined', testInvalidCommand, undefined, execa);18 unmodified lines71 test('$\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], $);72 test('$.sync\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], $.sync);73 74 const testRelativePath = async (t, execaMethod) => {68- const rootDir = basename(fileURLToPath(new URL('../..', import.meta.url)));69- const pathViaParentDir = join('..', rootDir, 'test', 'fixtures', 'noop.js');70- const {stdout} = await execaMethod(pathViaParentDir);75+ const rootDirectory = basename(fileURLToPath(new URL('../..', import.meta.url)));76+ const pathViaParentDirectory = join('..', rootDirectory, 'test', 'fixtures', 'noop.js');77+ const {stdout} = await execaMethod(pathViaParentDirectory);78 t.is(stdout, foobarString);79 };80 81 test('execa() use relative path with \'..\' chars', testRelativePath, execa);6 unmodified linesmodified:test/methods/parameters-options.js+54 added-47 removed
1 import {join} from 'node:path';2 import test from 'ava';3-import {execa, execaSync, execaCommand, execaCommandSync, execaNode, $} from '../../index.js';4-import {setFixtureDir, FIXTURES_DIR} from '../helpers/fixtures-dir.js';3+import {4+ execa,5+ execaSync,6+ execaCommand,7+ execaCommandSync,8+ execaNode,9+ $,10+} from '../../index.js';11+import {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';12 6-setFixtureDir();13+setFixtureDirectory();14 8-const NOOP_PATH = join(FIXTURES_DIR, 'noop.js');15+const NOOP_PATH = join(FIXTURES_DIRECTORY, 'noop.js');16 10-const testSerializeArg = async (t, arg, execaMethod) => {11- const {stdout} = await execaMethod(NOOP_PATH, [arg]);12- t.is(stdout, String(arg));17+const testSerializeArgument = async (t, commandArgument, execaMethod) => {18+ const {stdout} = await execaMethod(NOOP_PATH, [commandArgument]);19+ t.is(stdout, String(commandArgument));20 };21 15-test('execa()\'s arguments can be numbers', testSerializeArg, 1, execa);16-test('execa()\'s arguments can be booleans', testSerializeArg, true, execa);17-test('execa()\'s arguments can be NaN', testSerializeArg, Number.NaN, execa);18-test('execa()\'s arguments can be Infinity', testSerializeArg, Number.POSITIVE_INFINITY, execa);19-test('execa()\'s arguments can be null', testSerializeArg, null, execa);20-test('execa()\'s arguments can be undefined', testSerializeArg, undefined, execa);21-test('execa()\'s arguments can be bigints', testSerializeArg, 1n, execa);22-test('execa()\'s arguments can be symbols', testSerializeArg, Symbol('test'), execa);23-test('execaSync()\'s arguments can be numbers', testSerializeArg, 1, execaSync);24-test('execaSync()\'s arguments can be booleans', testSerializeArg, true, execaSync);25-test('execaSync()\'s arguments can be NaN', testSerializeArg, Number.NaN, execaSync);26-test('execaSync()\'s arguments can be Infinity', testSerializeArg, Number.POSITIVE_INFINITY, execaSync);27-test('execaSync()\'s arguments can be null', testSerializeArg, null, execaSync);28-test('execaSync()\'s arguments can be undefined', testSerializeArg, undefined, execaSync);29-test('execaSync()\'s arguments can be bigints', testSerializeArg, 1n, execaSync);30-test('execaSync()\'s arguments can be symbols', testSerializeArg, Symbol('test'), execaSync);31-test('execaNode()\'s arguments can be numbers', testSerializeArg, 1, execaNode);32-test('execaNode()\'s arguments can be booleans', testSerializeArg, true, execaNode);33-test('execaNode()\'s arguments can be NaN', testSerializeArg, Number.NaN, execaNode);34-test('execaNode()\'s arguments can be Infinity', testSerializeArg, Number.POSITIVE_INFINITY, execaNode);35-test('execaNode()\'s arguments can be null', testSerializeArg, null, execaNode);36-test('execaNode()\'s arguments can be undefined', testSerializeArg, undefined, execaNode);37-test('execaNode()\'s arguments can be bigints', testSerializeArg, 1n, execaNode);38-test('execaNode()\'s arguments can be symbols', testSerializeArg, Symbol('test'), execaNode);39-test('$\'s arguments can be numbers', testSerializeArg, 1, $);40-test('$\'s arguments can be booleans', testSerializeArg, true, $);41-test('$\'s arguments can be NaN', testSerializeArg, Number.NaN, $);42-test('$\'s arguments can be Infinity', testSerializeArg, Number.POSITIVE_INFINITY, $);43-test('$\'s arguments can be null', testSerializeArg, null, $);44-test('$\'s arguments can be undefined', testSerializeArg, undefined, $);45-test('$\'s arguments can be bigints', testSerializeArg, 1n, $);46-test('$\'s arguments can be symbols', testSerializeArg, Symbol('test'), $);47-test('$.sync\'s arguments can be numbers', testSerializeArg, 1, $.sync);48-test('$.sync\'s arguments can be booleans', testSerializeArg, true, $.sync);49-test('$.sync\'s arguments can be NaN', testSerializeArg, Number.NaN, $.sync);50-test('$.sync\'s arguments can be Infinity', testSerializeArg, Number.POSITIVE_INFINITY, $.sync);51-test('$.sync\'s arguments can be null', testSerializeArg, null, $.sync);52-test('$.sync\'s arguments can be undefined', testSerializeArg, undefined, $.sync);53-test('$.sync\'s arguments can be bigints', testSerializeArg, 1n, $.sync);54-test('$.sync\'s arguments can be symbols', testSerializeArg, Symbol('test'), $.sync);22+test('execa()\'s arguments can be numbers', testSerializeArgument, 1, execa);23+test('execa()\'s arguments can be booleans', testSerializeArgument, true, execa);24+test('execa()\'s arguments can be NaN', testSerializeArgument, Number.NaN, execa);25+test('execa()\'s arguments can be Infinity', testSerializeArgument, Number.POSITIVE_INFINITY, execa);26+test('execa()\'s arguments can be null', testSerializeArgument, null, execa);27+test('execa()\'s arguments can be undefined', testSerializeArgument, undefined, execa);28+test('execa()\'s arguments can be bigints', testSerializeArgument, 1n, execa);29+test('execa()\'s arguments can be symbols', testSerializeArgument, Symbol('test'), execa);30+test('execaSync()\'s arguments can be numbers', testSerializeArgument, 1, execaSync);31+test('execaSync()\'s arguments can be booleans', testSerializeArgument, true, execaSync);32+test('execaSync()\'s arguments can be NaN', testSerializeArgument, Number.NaN, execaSync);33+test('execaSync()\'s arguments can be Infinity', testSerializeArgument, Number.POSITIVE_INFINITY, execaSync);34+test('execaSync()\'s arguments can be null', testSerializeArgument, null, execaSync);35+test('execaSync()\'s arguments can be undefined', testSerializeArgument, undefined, execaSync);36+test('execaSync()\'s arguments can be bigints', testSerializeArgument, 1n, execaSync);37+test('execaSync()\'s arguments can be symbols', testSerializeArgument, Symbol('test'), execaSync);38+test('execaNode()\'s arguments can be numbers', testSerializeArgument, 1, execaNode);39+test('execaNode()\'s arguments can be booleans', testSerializeArgument, true, execaNode);40+test('execaNode()\'s arguments can be NaN', testSerializeArgument, Number.NaN, execaNode);41+test('execaNode()\'s arguments can be Infinity', testSerializeArgument, Number.POSITIVE_INFINITY, execaNode);42+test('execaNode()\'s arguments can be null', testSerializeArgument, null, execaNode);43+test('execaNode()\'s arguments can be undefined', testSerializeArgument, undefined, execaNode);44+test('execaNode()\'s arguments can be bigints', testSerializeArgument, 1n, execaNode);45+test('execaNode()\'s arguments can be symbols', testSerializeArgument, Symbol('test'), execaNode);46+test('$\'s arguments can be numbers', testSerializeArgument, 1, $);47+test('$\'s arguments can be booleans', testSerializeArgument, true, $);48+test('$\'s arguments can be NaN', testSerializeArgument, Number.NaN, $);49+test('$\'s arguments can be Infinity', testSerializeArgument, Number.POSITIVE_INFINITY, $);50+test('$\'s arguments can be null', testSerializeArgument, null, $);51+test('$\'s arguments can be undefined', testSerializeArgument, undefined, $);52+test('$\'s arguments can be bigints', testSerializeArgument, 1n, $);53+test('$\'s arguments can be symbols', testSerializeArgument, Symbol('test'), $);54+test('$.sync\'s arguments can be numbers', testSerializeArgument, 1, $.sync);55+test('$.sync\'s arguments can be booleans', testSerializeArgument, true, $.sync);56+test('$.sync\'s arguments can be NaN', testSerializeArgument, Number.NaN, $.sync);57+test('$.sync\'s arguments can be Infinity', testSerializeArgument, Number.POSITIVE_INFINITY, $.sync);58+test('$.sync\'s arguments can be null', testSerializeArgument, null, $.sync);59+test('$.sync\'s arguments can be undefined', testSerializeArgument, undefined, $.sync);60+test('$.sync\'s arguments can be bigints', testSerializeArgument, 1n, $.sync);61+test('$.sync\'s arguments can be symbols', testSerializeArgument, Symbol('test'), $.sync);62 63 const testInvalidOptions = async (t, execaMethod) => {64 t.throws(() => {65 execaMethod('echo', [], new Map());10 unmodified linesmodified:test/methods/promise.js+2 added-2 removed
1 import test from 'ava';2 import {execa} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 5-setFixtureDir();5+setFixtureDirectory();6 7 test('promise methods are not enumerable', t => {8 const descriptors = Object.getOwnPropertyDescriptors(execa('noop.js'));9 t.false(descriptors.then.enumerable);44 unmodified linesmodified:test/methods/script.js+2 added-2 removed
1 import test from 'ava';2 import {isStream} from 'is-stream';3 import {$} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {foobarString} from '../helpers/input.js';6 7-setFixtureDir();7+setFixtureDirectory();8 9 const testScriptStdoutSync = (t, getSubprocess, expectedStdout) => {10 const {stdout} = getSubprocess();11 t.is(stdout, expectedStdout);48 unmodified linesmodified:test/methods/template.js+2 added-2 removed
1 import test from 'ava';2 import {$} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 5-setFixtureDir();5+setFixtureDirectory();6 7 // Workaround since some text editors or IDEs do not allow inputting \r directly8 const escapedCall = string => {9 const templates = [string];320 unmodified linesmodified:test/pipe/abort.js+2 added-2 removed
1 import {once} from 'node:events';2 import test from 'ava';3 import {execa} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {foobarString} from '../helpers/input.js';6 7-setFixtureDir();7+setFixtureDirectory();8 9 const assertUnPipeError = async (t, pipePromise) => {10 const error = await t.throwsAsync(pipePromise);11 156 unmodified linesmodified:test/pipe/pipe-arguments.js+11 added-11 removed
1 import {spawn} from 'node:child_process';2 import {pathToFileURL} from 'node:url';3 import test from 'ava';4 import {$, execa} from '../../index.js';5-import {setFixtureDir, FIXTURES_DIR} from '../helpers/fixtures-dir.js';5+import {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';6 import {foobarString} from '../helpers/input.js';7 8-setFixtureDir();8+setFixtureDirectory();9 10 test('$.pipe(subprocess)', async t => {11 const {stdout} = await $`noop.js ${foobarString}`.pipe($({stdin: 'pipe'})`stdin.js`);12 t.is(stdout, foobarString);45 unmodified lines58 t.is(stdout, foobarString);59 });60 61 test('execa.$.pipe(fileUrl)`', async t => {62- const {stdout} = await execa('noop.js', [foobarString]).pipe(pathToFileURL(`${FIXTURES_DIR}/stdin.js`));62+ const {stdout} = await execa('noop.js', [foobarString]).pipe(pathToFileURL(`${FIXTURES_DIRECTORY}/stdin.js`));63 t.is(stdout, foobarString);64 });65 66-test('$.pipe("file", args, options)', async t => {67- const {stdout} = await $`noop.js ${foobarString}`.pipe('node', ['stdin.js'], {cwd: FIXTURES_DIR});66+test('$.pipe("file", commandArguments, options)', async t => {67+ const {stdout} = await $`noop.js ${foobarString}`.pipe('node', ['stdin.js'], {cwd: FIXTURES_DIRECTORY});68 t.is(stdout, foobarString);69 });70 71-test('execa.$.pipe("file", args, options)`', async t => {72- const {stdout} = await execa('noop.js', [foobarString]).pipe('node', ['stdin.js'], {cwd: FIXTURES_DIR});71+test('execa.$.pipe("file", commandArguments, options)`', async t => {72+ const {stdout} = await execa('noop.js', [foobarString]).pipe('node', ['stdin.js'], {cwd: FIXTURES_DIRECTORY});73 t.is(stdout, foobarString);74 });75 76-test('$.pipe.pipe("file", args, options)', async t => {76+test('$.pipe.pipe("file", commandArguments, options)', async t => {77 const {stdout} = await $`noop.js ${foobarString}`78 .pipe`stdin.js`79- .pipe('node', ['stdin.js'], {cwd: FIXTURES_DIR});79+ .pipe('node', ['stdin.js'], {cwd: FIXTURES_DIRECTORY});80 t.is(stdout, foobarString);81 });82 83 test('$.pipe(subprocess, pipeOptions)', async t => {176 unmodified lines260 {message: /Please use \.pipe/},261 );262 });263 264-const testInvalidPipe = async (t, ...args) => {264+const testInvalidPipe = async (t, ...pipeArguments) => {265 await t.throwsAsync(266- $`empty.js`.pipe(...args),266+ $`empty.js`.pipe(...pipeArguments),267 {message: /must be a template string/},268 );269 };270 2 unmodified linesmodified:test/pipe/sequence.js+2 added-2 removed
1 unmodified line2 import process from 'node:process';3 import {PassThrough} from 'node:stream';4 import test from 'ava';5 import {execa} from '../../index.js';6-import {setFixtureDir} from '../helpers/fixtures-dir.js';6+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';7 import {foobarString} from '../helpers/input.js';8 import {noopGenerator} from '../helpers/generator.js';9 import {prematureClose} from '../helpers/stdio.js';10 11-setFixtureDir();11+setFixtureDirectory();12 13 const isLinux = process.platform === 'linux';14 15 test('Source stream abort -> destination success', async t => {298 unmodified linesmodified:test/pipe/setup.js+2 added-2 removed
1 import test from 'ava';2 import {execa} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {fullStdio, fullReadableStdio} from '../helpers/stdio.js';5 import {foobarString} from '../helpers/input.js';6 7-setFixtureDir();7+setFixtureDirectory();8 9 // eslint-disable-next-line max-params10 const pipeToSubprocess = async (t, readableFdNumber, writableFdNumber, from, to, readableOptions = {}, writableOptions = {}) => {11 const {stdout} = await execa('noop-fd.js', [`${readableFdNumber}`, foobarString], readableOptions)17 unmodified linesmodified:test/pipe/streaming.js+2 added-2 removed
1 import {once} from 'node:events';2 import {PassThrough} from 'node:stream';3 import test from 'ava';4 import {execa} from '../../index.js';5-import {setFixtureDir} from '../helpers/fixtures-dir.js';5+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6 import {foobarString} from '../helpers/input.js';7 import {assertMaxListeners} from '../helpers/listeners.js';8 import {fullReadableStdio} from '../helpers/stdio.js';9 10-setFixtureDir();10+setFixtureDirectory();11 12 test('Can pipe two sources to same destination', async t => {13 const source = execa('noop.js', [foobarString]);14 const secondSource = execa('noop.js', [foobarString]);427 unmodified linesmodified:test/pipe/throw.js+2 added-2 removed
1 import test from 'ava';2 import {execa} from '../../index.js';3 import {foobarString} from '../helpers/input.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {assertPipeError} from '../helpers/pipe.js';6 7-setFixtureDir();7+setFixtureDirectory();8 9 test('Destination stream is ended when first argument is invalid', async t => {10 const source = execa('empty.js', {stdout: 'ignore'});11 const destination = execa('stdin.js');27 unmodified linesmodified:test/resolve/all.js+9 added-3 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {defaultHighWaterMark} from '../helpers/stream.js';5 import {foobarString} from '../helpers/input.js';6 7-setFixtureDir();7+setFixtureDirectory();8 9 const textEncoder = new TextEncoder();10 const foobarStringFull = `${foobarString}\n`;11 const doubleFoobarStringFull = `${foobarStringFull}${foobarStringFull}`;5 unmodified lines17 18 // eslint-disable-next-line max-params19 const testAllBoth = async (t, expectedOutput, encoding, lines, stripFinalNewline, isFailure, execaMethod) => {20 const fixtureName = isFailure ? 'noop-both-fail.js' : 'noop-both.js';21- const {exitCode, all} = await execaMethod(fixtureName, [foobarString], {all: true, encoding, lines, stripFinalNewline, reject: !isFailure});21+ const {exitCode, all} = await execaMethod(fixtureName, [foobarString], {22+ all: true,23+ encoding,24+ lines,25+ stripFinalNewline,26+ reject: !isFailure,27+ });28 t.is(exitCode, isFailure ? 1 : 0);29 t.deepEqual(all, expectedOutput);30 };31 146 unmodified linesmodified:test/resolve/buffer-end.js+2 added-2 removed
1 import {once} from 'node:events';2 import {setTimeout} from 'node:timers/promises';3 import test from 'ava';4 import {execa} from '../../index.js';5-import {setFixtureDir} from '../helpers/fixtures-dir.js';5+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6 import {fullStdio, getStdio} from '../helpers/stdio.js';7 8-setFixtureDir();8+setFixtureDirectory();9 10 const testBufferIgnore = async (t, fdNumber, all) => {11 await t.notThrowsAsync(execa('max-buffer.js', [`${fdNumber}`], {...getStdio(fdNumber, 'ignore'), buffer: false, all}));12 };66 unmodified linesmodified:test/resolve/exit.js+2 added-2 removed
1 import process from 'node:process';2 import test from 'ava';3 import {execa} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 6 const isWindows = process.platform === 'win32';7 8-setFixtureDir();8+setFixtureDirectory();9 10 test('exitCode is 0 on success', async t => {11 const {exitCode} = await execa('noop.js', ['foo']);12 t.is(exitCode, 0);73 unmodified linesmodified:test/resolve/no-buffer.js+2 added-2 removed
1 import {once} from 'node:events';2 import test from 'ava';3 import getStream from 'get-stream';4 import {execa, execaSync} from '../../index.js';5-import {setFixtureDir} from '../helpers/fixtures-dir.js';5+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6 import {fullStdio, getStdio} from '../helpers/stdio.js';7 import {foobarString, foobarUppercase, foobarUppercaseUint8Array} from '../helpers/input.js';8 import {resultGenerator, uppercaseGenerator, uppercaseBufferGenerator} from '../helpers/generator.js';9 10-setFixtureDir();10+setFixtureDirectory();11 12 const testLateStream = async (t, fdNumber, all) => {13 const subprocess = execa('noop-fd-ipc.js', [`${fdNumber}`, foobarString], {...getStdio(4, 'ipc', 4), buffer: false, all});14 await once(subprocess, 'message');178 unmodified linesmodified:test/resolve/stdio.js+8 added-3 removed
1 import {setTimeout} from 'node:timers/promises';2 import test from 'ava';3 import {execa} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';5-import {fullStdio, getStdio, prematureClose, assertEpipe} from '../helpers/stdio.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5+import {6+ fullStdio,7+ getStdio,8+ prematureClose,9+ assertEpipe,10+} from '../helpers/stdio.js';11 import {infiniteGenerator} from '../helpers/generator.js';12 8-setFixtureDir();13+setFixtureDirectory();14 15 const getStreamInputSubprocess = fdNumber => execa('stdin-fd.js', [`${fdNumber}`], fdNumber === 316 ? getStdio(3, [new Uint8Array(), infiniteGenerator()])17 : {});105 unmodified linesmodified:test/resolve/wait-abort.js+8 added-3 removed
1 import {setImmediate} from 'node:timers/promises';2 import test from 'ava';3 import {execa} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {prematureClose} from '../helpers/stdio.js';6 import {noopReadable, noopWritable, noopDuplex} from '../helpers/stream.js';7-import {endOptionStream, destroyOptionStream, destroySubprocessStream, getStreamStdio} from '../helpers/wait.js';7+import {8+ endOptionStream,9+ destroyOptionStream,10+ destroySubprocessStream,11+ getStreamStdio,12+} from '../helpers/wait.js';13 9-setFixtureDir();14+setFixtureDirectory();15 16 const noop = () => {};17 18 // eslint-disable-next-line max-params86 unmodified linesmodified:test/resolve/wait-epipe.js+8 added-3 removed
1 import {setImmediate} from 'node:timers/promises';2 import test from 'ava';3 import {execa} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {assertEpipe} from '../helpers/stdio.js';6 import {foobarString} from '../helpers/input.js';7 import {noopWritable, noopDuplex} from '../helpers/stream.js';8-import {endOptionStream, destroyOptionStream, destroySubprocessStream, getStreamStdio} from '../helpers/wait.js';8+import {9+ endOptionStream,10+ destroyOptionStream,11+ destroySubprocessStream,12+ getStreamStdio,13+} from '../helpers/wait.js';14 10-setFixtureDir();15+setFixtureDirectory();16 17 // eslint-disable-next-line max-params18 const testStreamEpipeFail = async (t, streamMethod, stream, fdNumber, useTransform) => {19 const subprocess = execa('noop-stdin-fd.js', [`${fdNumber}`], getStreamStdio(fdNumber, stream, useTransform));41 unmodified linesmodified:test/resolve/wait-error.js+8 added-3 removed
1 import test from 'ava';2 import {execa} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {noopReadable, noopWritable, noopDuplex} from '../helpers/stream.js';5 import {destroyOptionStream, destroySubprocessStream, getStreamStdio} from '../helpers/wait.js';6 7-setFixtureDir();7+setFixtureDirectory();8 9 // eslint-disable-next-line max-params10 const testStreamError = async (t, streamMethod, stream, fdNumber, useTransform) => {11 const subprocess = execa('empty.js', getStreamStdio(fdNumber, stream, useTransform));12 const cause = new Error('test');13- streamMethod({stream, subprocess, fdNumber, error: cause});13+ streamMethod({14+ stream,15+ subprocess,16+ fdNumber,17+ error: cause,18+ });19 20 const error = await t.throwsAsync(subprocess);21 t.is(error.cause, cause);22 t.is(error.exitCode, 0);42 unmodified linesmodified:test/resolve/wait-subprocess.js+2 added-2 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {getStdio} from '../helpers/stdio.js';5 6-setFixtureDir();6+setFixtureDirectory();7 8 const testIgnore = async (t, fdNumber, execaMethod) => {9 const result = await execaMethod('noop.js', getStdio(fdNumber, 'ignore'));10 t.is(result.stdio[fdNumber], undefined);39 unmodified linesmodified:test/return/duration.js+2 added-2 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {getEarlyErrorSubprocess, getEarlyErrorSubprocessSync} from '../helpers/early-error.js';5 6-setFixtureDir();6+setFixtureDirectory();7 8 const assertDurationMs = (t, durationMs) => {9 t.is(typeof durationMs, 'number');10 t.true(Number.isFinite(durationMs));51 unmodified linesmodified:test/return/early-error.js+8 added-3 removed
1 import process from 'node:process';2 import test from 'ava';3 import {execa, execaSync, $} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {fullStdio} from '../helpers/stdio.js';6-import {earlyErrorOptions, getEarlyErrorSubprocess, getEarlyErrorSubprocessSync, expectedEarlyError} from '../helpers/early-error.js';6+import {7+ earlyErrorOptions,8+ getEarlyErrorSubprocess,9+ getEarlyErrorSubprocessSync,10+ expectedEarlyError,11+} from '../helpers/early-error.js';12 8-setFixtureDir();13+setFixtureDirectory();14 15 const isWindows = process.platform === 'win32';16 const ENOENT_REGEXP = isWindows ? /failed with exit code 1/ : /spawn.* ENOENT/;17 96 unmodified linesmodified:test/return/final-error.js+8 added-3 removed
1 import test from 'ava';2-import {execa, execaSync, ExecaError, ExecaSyncError} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';2+import {3+ execa,4+ execaSync,5+ ExecaError,6+ ExecaSyncError,7+} from '../../index.js';8+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';9 import {foobarString} from '../helpers/input.js';10 import {getEarlyErrorSubprocess, getEarlyErrorSubprocessSync} from '../helpers/early-error.js';11 7-setFixtureDir();12+setFixtureDirectory();13 14 const testUnusualError = async (t, error, expectedOriginalMessage = String(error)) => {15 const subprocess = execa('empty.js');16 subprocess.emit('error', error);147 unmodified linesmodified:test/return/message.js+8 added-3 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {fullStdio, getStdio} from '../helpers/stdio.js';5 import {foobarString} from '../helpers/input.js';6 import {QUOTE} from '../helpers/verbose.js';7 import {noopGenerator, outputObjectGenerator} from '../helpers/generator.js';8 9-setFixtureDir();9+setFixtureDirectory();10 11 test('error.message contains the command', async t => {12 await t.throwsAsync(execa('exit.js', ['2', 'foo', 'bar']), {message: /exit.js 2 foo bar/});13 });14 15 // eslint-disable-next-line max-params16 const testStdioMessage = async (t, encoding, all, objectMode, execaMethod) => {17- const {exitCode, message} = await execaMethod('echo-fail.js', {...getStdio(1, noopGenerator(objectMode, false, true), 4), encoding, all, reject: false});17+ const {exitCode, message} = await execaMethod('echo-fail.js', {18+ ...getStdio(1, noopGenerator(objectMode, false, true), 4),19+ encoding,20+ all,21+ reject: false,22+ });23 t.is(exitCode, 1);24 const output = all ? 'stdout\nstderr' : 'stderr\n\nstdout';25 t.true(message.endsWith(`echo-fail.js\n\n${output}\n\nfd3`));26 };70 unmodified linesmodified:test/return/output.js+2 added-2 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {fullStdio, getStdio} from '../helpers/stdio.js';5 import {foobarString} from '../helpers/input.js';6 7-setFixtureDir();7+setFixtureDirectory();8 9 const testOutput = async (t, fdNumber, execaMethod) => {10 const {stdout, stderr, stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], fullStdio);11 t.is(stdio[fdNumber], foobarString);99 unmodified linesmodified:test/return/reject.js+2 added-2 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 5-setFixtureDir();5+setFixtureDirectory();6 7 test('skip throwing when using reject option', async t => {8 const {exitCode} = await execa('fail.js', {reject: false});9 t.is(exitCode, 2);6 unmodified linesmodified:test/return/result.js+2 added-2 removed
1 import process from 'node:process';2 import test from 'ava';3 import {execa, execaSync} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {fullStdio} from '../helpers/stdio.js';6 7 const isWindows = process.platform === 'win32';8 9-setFixtureDir();9+setFixtureDirectory();10 11 const testSuccessShape = async (t, execaMethod) => {12 const result = await execaMethod('empty.js', {...fullStdio, all: true});13 t.deepEqual(Reflect.ownKeys(result), [132 unmodified linesmodified:test/stdio/direction.js+2 added-2 removed
2 unmodified lines3 import test from 'ava';4 import tempfile from 'tempfile';5 import {execa, execaSync} from '../../index.js';6 import {getStdio} from '../helpers/stdio.js';7-import {setFixtureDir} from '../helpers/fixtures-dir.js';7+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';8 9-setFixtureDir();9+setFixtureDirectory();10 11 const testInputOutput = (t, stdioOption, execaMethod) => {12 t.throws(() => {13 execaMethod('empty.js', getStdio(3, [new ReadableStream(), stdioOption]));37 unmodified linesmodified:test/stdio/duplex.js+8 added-3 removed
1 unmodified line2 import {promisify} from 'node:util';3 import {createGzip, gunzip} from 'node:zlib';4 import test from 'ava';5 import {execa} from '../../index.js';6-import {setFixtureDir} from '../helpers/fixtures-dir.js';7-import {foobarString, foobarObject, foobarUppercase, foobarUppercaseHex} from '../helpers/input.js';6+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';7+import {8+ foobarString,9+ foobarObject,10+ foobarUppercase,11+ foobarUppercaseHex,12+} from '../helpers/input.js';13 import {uppercaseEncodingDuplex, getOutputDuplex} from '../helpers/duplex.js';14 10-setFixtureDir();15+setFixtureDirectory();16 17 test('Can use crypto.createHash()', async t => {18 const {stdout} = await execa('noop-fd.js', ['1', foobarString], {stdout: {transform: createHash('sha1')}, encoding: 'hex'});19 const expectedStdout = createHash('sha1').update(foobarString).digest('hex');43 unmodified linesmodified:test/stdio/file-descriptor.js+2 added-2 removed
1 import {readFile, open, rm} from 'node:fs/promises';2 import test from 'ava';3 import tempfile from 'tempfile';4 import {execa, execaSync} from '../../index.js';5-import {setFixtureDir} from '../helpers/fixtures-dir.js';5+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6 import {getStdio} from '../helpers/stdio.js';7 8-setFixtureDir();8+setFixtureDirectory();9 10 const testFileDescriptorOption = async (t, fdNumber, execaMethod) => {11 const filePath = tempfile();12 const fileDescriptor = await open(filePath, 'w');22 unmodified linesmodified:test/stdio/file-path-error.js+8 added-3 removed
2 unmodified lines3 import test from 'ava';4 import {pathExists} from 'path-exists';5 import tempfile from 'tempfile';6 import {execa, execaSync} from '../../index.js';7-import {setFixtureDir} from '../helpers/fixtures-dir.js';7+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';8 import {identity, getStdio} from '../helpers/stdio.js';9 import {foobarString, foobarUppercase} from '../helpers/input.js';10-import {outputObjectGenerator, uppercaseGenerator, serializeGenerator, throwingGenerator} from '../helpers/generator.js';10+import {11+ outputObjectGenerator,12+ uppercaseGenerator,13+ serializeGenerator,14+ throwingGenerator,15+} from '../helpers/generator.js';16 import {getAbsolutePath} from '../helpers/file-path.js';17 13-setFixtureDir();18+setFixtureDirectory();19 20 const nonFileUrl = new URL('https://example.com');21 22 const testStdioNonFileUrl = (t, fdNumber, execaMethod) => {151 unmodified linesmodified:test/stdio/file-path-main.js+8 added-3 removed
3 unmodified lines4 import {pathToFileURL} from 'node:url';5 import test from 'ava';6 import tempfile from 'tempfile';7 import {execa, execaSync} from '../../index.js';8-import {setFixtureDir} from '../helpers/fixtures-dir.js';8+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';9 import {identity, getStdio} from '../helpers/stdio.js';10-import {runExeca, runExecaSync, runScript, runScriptSync} from '../helpers/run.js';10+import {11+ runExeca,12+ runExecaSync,13+ runScript,14+ runScriptSync,15+} from '../helpers/run.js';16 import {foobarString, foobarUint8Array} from '../helpers/input.js';17 import {getAbsolutePath, getRelativePath} from '../helpers/file-path.js';18 14-setFixtureDir();19+setFixtureDirectory();20 21 const getStdioInput = (fdNumberOrName, file) => {22 if (fdNumberOrName === 'string') {23 return {input: foobarString};137 unmodified linesmodified:test/stdio/file-path-mixed.js+2 added-2 removed
1 unmodified line2 import {pathToFileURL} from 'node:url';3 import test from 'ava';4 import tempfile from 'tempfile';5 import {execa, execaSync} from '../../index.js';6-import {setFixtureDir} from '../helpers/fixtures-dir.js';6+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';7 import {getStdio} from '../helpers/stdio.js';8 import {foobarString, foobarUppercase} from '../helpers/input.js';9 import {uppercaseGenerator} from '../helpers/generator.js';10 import {getAbsolutePath} from '../helpers/file-path.js';11 12-setFixtureDir();12+setFixtureDirectory();13 14 const testInputFileTransform = async (t, fdNumber, mapFile, execaMethod) => {15 const filePath = tempfile();16 await writeFile(filePath, foobarString);78 unmodified linesmodified:test/stdio/forward.js+2 added-2 removed
1 import test from 'ava';2 import {execa} from '../../index.js';3 import {getStdio} from '../helpers/stdio.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {foobarString, foobarUint8Array} from '../helpers/input.js';6 7-setFixtureDir();7+setFixtureDirectory();8 9 const testInputOverlapped = async (t, fdNumber) => {10 const {stdout} = await execa('stdin-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, [foobarUint8Array, 'overlapped', 'pipe']));11 t.is(stdout, foobarString);36 unmodified linesmodified:test/stdio/handle-invalid.js+2 added-2 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3 import {getStdio} from '../helpers/stdio.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 6-setFixtureDir();6+setFixtureDirectory();7 8 const testEmptyArray = (t, fdNumber, optionName, execaMethod) => {9 t.throws(() => {10 execaMethod('empty.js', getStdio(fdNumber, []));50 unmodified linesmodified:test/stdio/handle-options.js+2 added-2 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3 import {getStdio} from '../helpers/stdio.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {appendGenerator, appendAsyncGenerator, casedSuffix} from '../helpers/generator.js';6 import {appendDuplex} from '../helpers/duplex.js';7 import {appendWebTransform} from '../helpers/web-transform.js';8 import {foobarString} from '../helpers/input.js';9 10-setFixtureDir();10+setFixtureDirectory();11 12 const testNoPipeOption = async (t, stdioOption, fdNumber) => {13 const subprocess = execa('empty.js', getStdio(fdNumber, stdioOption));14 t.is(subprocess.stdio[fdNumber], null);58 unmodified linesmodified:test/stdio/iterable.js+15 added-5 removed
1 import {once} from 'node:events';2 import {setImmediate} from 'node:timers/promises';3 import test from 'ava';4 import {execa, execaSync} from '../../index.js';5-import {setFixtureDir} from '../helpers/fixtures-dir.js';5+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6 import {getStdio} from '../helpers/stdio.js';7-import {foobarString, foobarObject, foobarObjectString, foobarArray} from '../helpers/input.js';8-import {noopGenerator, serializeGenerator, infiniteGenerator, throwingGenerator} from '../helpers/generator.js';7+import {8+ foobarString,9+ foobarObject,10+ foobarObjectString,11+ foobarArray,12+} from '../helpers/input.js';13+import {14+ noopGenerator,15+ serializeGenerator,16+ infiniteGenerator,17+ throwingGenerator,18+} from '../helpers/generator.js';19 20 const stringGenerator = function * () {21 yield * foobarArray;22 };17 unmodified lines40 await setImmediate();41 yield * foobarArray;42 };43 34-setFixtureDir();44+setFixtureDirectory();45 46 const testIterable = async (t, stdioOption, fdNumber, execaMethod) => {47 const {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, stdioOption));48 t.is(stdout, 'foobar');147 unmodified lines196 197 test('stdin option iterable is canceled on subprocess error', async t => {198 const iterable = infiniteGenerator().transform();199 await t.throwsAsync(execa('stdin.js', {stdin: iterable, timeout: 1}), {message: /timed out/});190- // eslint-disable-next-line no-unused-vars, no-empty200+ // eslint-disable-next-line no-empty201 for await (const _ of iterable) {}202 });modified:test/stdio/lines-main.js+2 added-2 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {fullStdio} from '../helpers/stdio.js';5 import {getOutputsGenerator} from '../helpers/generator.js';6 import {foobarString} from '../helpers/input.js';7 import {5 unmodified lines13 noNewlinesChunks,14 getSimpleChunkSubprocessAsync,15 } from '../helpers/lines.js';16 17-setFixtureDir();17+setFixtureDirectory();18 19 // eslint-disable-next-line max-params20 const testStreamLines = async (t, fdNumber, input, expectedOutput, lines, stripFinalNewline, execaMethod) => {21 const {stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`, input], {...fullStdio, lines, stripFinalNewline});87 unmodified linesmodified:test/stdio/lines-max-buffer.js+2 added-2 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {simpleLines, noNewlinesChunks, getSimpleChunkSubprocessAsync} from '../helpers/lines.js';5 import {assertErrorMessage} from '../helpers/max-buffer.js';6 7-setFixtureDir();7+setFixtureDirectory();8 9 const maxBuffer = simpleLines.length - 1;10 11 const testBelowMaxBuffer = async (t, lines) => {39 unmodified linesmodified:test/stdio/lines-mixed.js+8 added-3 removed
1 import {Writable} from 'node:stream';2 import test from 'ava';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {assertStreamOutput, assertStreamDataEvents, assertIterableChunks} from '../helpers/convert.js';5-import {simpleFull, simpleLines, noNewlinesChunks, getSimpleChunkSubprocessAsync} from '../helpers/lines.js';5+import {6+ simpleFull,7+ simpleLines,8+ noNewlinesChunks,9+ getSimpleChunkSubprocessAsync,10+} from '../helpers/lines.js';11 7-setFixtureDir();12+setFixtureDirectory();13 14 const testAsyncIteration = async (t, expectedLines, stripFinalNewline) => {15 const subprocess = getSimpleChunkSubprocessAsync({stripFinalNewline});16 t.false(subprocess.stdout.readableObjectMode);44 unmodified linesmodified:test/stdio/lines-noop.js+8 added-3 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {getOutputsGenerator} from '../helpers/generator.js';5 import {foobarObject} from '../helpers/input.js';6 import {7 simpleFull,4 unmodified lines12 noNewlinesChunks,13 getSimpleChunkSubprocess,14 } from '../helpers/lines.js';15 16-setFixtureDir();16+setFixtureDirectory();17 18 const testStreamLinesNoop = async (t, lines, execaMethod) => {19 const {stdout} = await execaMethod('noop-fd.js', ['1', simpleFull], {lines});20 t.is(stdout, simpleFull);20 unmodified lines41 test('"lines: true" is a noop with objects generators, fd-specific, objectMode, sync', testLinesObjectMode, {stdout: true}, execaSync);42 43 // eslint-disable-next-line max-params44 const testEncoding = async (t, input, expectedOutput, encoding, lines, stripFinalNewline, execaMethod) => {45- const {stdout} = await execaMethod('stdin.js', {lines, stripFinalNewline, encoding, input});45+ const {stdout} = await execaMethod('stdin.js', {46+ lines,47+ stripFinalNewline,48+ encoding,49+ input,50+ });51 t.deepEqual(stdout, expectedOutput);52 };53 54 test('"lines: true" is a noop with "encoding: utf16"', testEncoding, simpleFullUtf16Uint8Array, simpleLines, 'utf16le', true, false, execa);35 unmodified linesmodified:test/stdio/native-fd.js+2 added-2 removed
1 import {platform} from 'node:process';2 import test from 'ava';3 import {execa, execaSync} from '../../index.js';4 import {getStdio, fullStdio} from '../helpers/stdio.js';5-import {setFixtureDir} from '../helpers/fixtures-dir.js';5+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6 import {foobarString} from '../helpers/input.js';7 import {parentExecaAsync, parentExecaSync} from '../helpers/nested.js';8 9-setFixtureDir();9+setFixtureDirectory();10 11 const isLinux = platform === 'linux';12 const isWindows = platform === 'win32';13 63 unmodified linesmodified:test/stdio/native-inherit-pipe.js+2 added-2 removed
1 unmodified line2 import test from 'ava';3 import tempfile from 'tempfile';4 import {execa} from '../../index.js';5 import {getStdio, fullStdio} from '../helpers/stdio.js';6-import {setFixtureDir} from '../helpers/fixtures-dir.js';6+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';7 import {foobarString} from '../helpers/input.js';8 import {parentExecaAsync, parentExecaSync} from '../helpers/nested.js';9 10-setFixtureDir();10+setFixtureDirectory();11 12 const testInheritStdin = async (t, stdioOption, isSync) => {13 const {stdout} = await execa('nested-multiple-stdin.js', [JSON.stringify(stdioOption), `${isSync}`], {input: foobarString});14 t.is(stdout, `${foobarString}${foobarString}`);83 unmodified linesmodified:test/stdio/native-redirect.js+2 added-2 removed
1 import test from 'ava';2 import {execa} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {foobarString} from '../helpers/input.js';5 6-setFixtureDir();6+setFixtureDirectory();7 8 // eslint-disable-next-line max-params9 const testRedirect = async (t, stdioOption, fdNumber, isInput, isSync) => {10 const {fixtureName, ...options} = isInput65 unmodified linesmodified:test/stdio/node-stream-custom.js+2 added-2 removed
5 unmodified lines6 import {callbackify} from 'node:util';7 import test from 'ava';8 import tempfile from 'tempfile';9 import {execa, execaSync} from '../../index.js';10-import {setFixtureDir} from '../helpers/fixtures-dir.js';10+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';11 import {getStdio} from '../helpers/stdio.js';12 import {foobarString} from '../helpers/input.js';13 import {noopReadable, noopWritable} from '../helpers/stream.js';14 15-setFixtureDir();15+setFixtureDirectory();16 17 const testLazyFileReadable = async (t, fdNumber) => {18 const filePath = tempfile();19 await writeFile(filePath, 'foobar');139 unmodified linesmodified:test/stdio/node-stream-native.js+8 added-3 removed
2 unmodified lines3 import {readFile, writeFile, rm} from 'node:fs/promises';4 import test from 'ava';5 import tempfile from 'tempfile';6 import {execa, execaSync} from '../../index.js';7-import {setFixtureDir} from '../helpers/fixtures-dir.js';7+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';8 import {getStdio} from '../helpers/stdio.js';9 import {foobarString} from '../helpers/input.js';10-import {noopReadable, noopWritable, noopDuplex, simpleReadable} from '../helpers/stream.js';10+import {11+ noopReadable,12+ noopWritable,13+ noopDuplex,14+ simpleReadable,15+} from '../helpers/stream.js';16 12-setFixtureDir();17+setFixtureDirectory();18 19 const testNoFileStreamSync = async (t, fdNumber, stream) => {20 t.throws(() => {21 execaSync('empty.js', getStdio(fdNumber, stream));164 unmodified linesmodified:test/stdio/stdio-option.js+3 added-6 removed
1 import {inspect} from 'node:util';2 import test from 'ava';3 import {normalizeStdioOption} from '../../lib/stdio/stdio-option.js';4 5-const macro = (t, input, expected, func) => {5+const stdioMacro = (t, input, expected) => {6 if (expected instanceof Error) {7 t.throws(() => {8 normalizeStdioOption(input);9 }, {message: expected.message});10 return;11 }12 13- t.deepEqual(func(input), expected);13+ t.deepEqual(normalizeStdioOption(input), expected);14 };15 16-const macroTitle = name => (title, input) => `${name} ${(inspect(input))}`;16+stdioMacro.title = (_, input) => `execa() ${(inspect(input))}`;17 18-const stdioMacro = (...args) => macro(...args, normalizeStdioOption);19-stdioMacro.title = macroTitle('execa()');20-18 test(stdioMacro, {stdio: 'inherit'}, ['inherit', 'inherit', 'inherit']);19 test(stdioMacro, {stdio: 'pipe'}, ['pipe', 'pipe', 'pipe']);20 test(stdioMacro, {stdio: 'ignore'}, ['ignore', 'ignore', 'ignore']);21 33 unmodified linesmodified:test/stdio/type.js+2 added-2 removed
3 unmodified lines4 import {noopGenerator, uppercaseGenerator} from '../helpers/generator.js';5 import {uppercaseBufferDuplex} from '../helpers/duplex.js';6 import {uppercaseBufferWebTransform} from '../helpers/web-transform.js';7 import {generatorsMap} from '../helpers/map.js';8-import {setFixtureDir} from '../helpers/fixtures-dir.js';8+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';9 10-setFixtureDir();10+setFixtureDirectory();11 12 const testInvalidGenerator = (t, fdNumber, stdioOption, execaMethod) => {13 t.throws(() => {14 execaMethod('empty.js', getStdio(fdNumber, {...noopGenerator(), ...stdioOption}));116 unmodified linesmodified:test/stdio/typed-array.js+2 added-2 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {getStdio} from '../helpers/stdio.js';5 import {foobarUint8Array, foobarString} from '../helpers/input.js';6 7-setFixtureDir();7+setFixtureDirectory();8 9 const testUint8Array = async (t, fdNumber, execaMethod) => {10 const {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, foobarUint8Array));11 t.is(stdout, foobarString);16 unmodified linesmodified:test/stdio/web-stream.js+2 added-2 removed
1 import {Readable} from 'node:stream';2 import {setImmediate} from 'node:timers/promises';3 import test from 'ava';4 import {execa, execaSync} from '../../index.js';5-import {setFixtureDir} from '../helpers/fixtures-dir.js';5+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6 import {getStdio} from '../helpers/stdio.js';7 8-setFixtureDir();8+setFixtureDirectory();9 10 const testReadableStream = async (t, fdNumber) => {11 const readableStream = Readable.toWeb(Readable.from('foobar'));12 const {stdout} = await execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, readableStream));86 unmodified linesmodified:test/stdio/web-transform.js+2 added-2 removed
1 import {promisify} from 'node:util';2 import {gunzip} from 'node:zlib';3 import test from 'ava';4 import {execa} from '../../index.js';5-import {setFixtureDir} from '../helpers/fixtures-dir.js';5+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6 import {foobarString, foobarUtf16Uint8Array, foobarUint8Array} from '../helpers/input.js';7 8-setFixtureDir();8+setFixtureDirectory();9 10 test('Can use CompressionStream()', async t => {11 const {stdout} = await execa('noop-fd.js', ['1', foobarString], {stdout: new CompressionStream('gzip'), encoding: 'buffer'});12 const decompressedStdout = await promisify(gunzip)(stdout);11 unmodified linesmodified:test/terminate/cancel.js+2 added-2 removed
1 import {once} from 'node:events';2 import test from 'ava';3 import {execa, execaSync} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 6-setFixtureDir();6+setFixtureDirectory();7 8 test('result.isCanceled is false when abort isn\'t called (success)', async t => {9 const {isCanceled} = await execa('noop.js');10 t.false(isCanceled);82 unmodified linesmodified:test/terminate/cleanup.js+2 added-2 removed
2 unmodified lines3 import test from 'ava';4 import {pEvent} from 'p-event';5 import isRunning from 'is-running';6 import {execa, execaSync} from '../../index.js';7-import {setFixtureDir} from '../helpers/fixtures-dir.js';7+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';8 import {nestedExecaAsync, nestedWorker} from '../helpers/nested.js';9 import {foobarString} from '../helpers/input.js';10 11-setFixtureDir();11+setFixtureDirectory();12 13 const isWindows = process.platform === 'win32';14 15 // When subprocess exits before current process87 unmodified linesmodified:test/terminate/kill-error.js+2 added-2 removed
1 unmodified line2 import {setImmediate} from 'node:timers/promises';3 import test from 'ava';4 import isRunning from 'is-running';5 import {execa} from '../../index.js';6-import {setFixtureDir} from '../helpers/fixtures-dir.js';6+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';7 8-setFixtureDir();8+setFixtureDirectory();9 10 test('.kill(error) propagates error', async t => {11 const subprocess = execa('forever.js');12 const originalMessage = 'test';71 unmodified linesmodified:test/terminate/kill-force.js+2 added-2 removed
4 unmodified lines5 import test from 'ava';6 import {pEvent} from 'p-event';7 import isRunning from 'is-running';8 import {execa} from '../../index.js';9-import {setFixtureDir} from '../helpers/fixtures-dir.js';9+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';10 import {assertMaxListeners} from '../helpers/listeners.js';11 12-setFixtureDir();12+setFixtureDirectory();13 14 const isWindows = process.platform === 'win32';15 16 const spawnNoKillable = async (forceKillAfterDelay, options) => {124 unmodified linesmodified:test/terminate/kill-signal.js+2 added-2 removed
1 import {once} from 'node:events';2 import {setImmediate} from 'node:timers/promises';3 import test from 'ava';4 import {execa} from '../../index.js';5-import {setFixtureDir} from '../helpers/fixtures-dir.js';5+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6 7-setFixtureDir();7+setFixtureDirectory();8 9 test('Can call `.kill()` multiple times', async t => {10 const subprocess = execa('forever.js');11 subprocess.kill();84 unmodified linesmodified:test/terminate/timeout.js+3 added-3 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir, FIXTURES_DIR} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';4 5-setFixtureDir();5+setFixtureDirectory();6 7 test('timeout kills the subprocess if it times out', async t => {8 const {isTerminated, signal, timedOut, originalMessage, shortMessage, message} = await t.throwsAsync(execa('forever.js', {timeout: 1}));9 t.true(isTerminated);5 unmodified lines15 });16 17 test('timeout kills the subprocess if it times out, in sync mode', async t => {18 const {isTerminated, signal, timedOut, originalMessage, shortMessage, message} = await t.throws(() => {19- execaSync('node', ['forever.js'], {timeout: 1, cwd: FIXTURES_DIR});19+ execaSync('node', ['forever.js'], {timeout: 1, cwd: FIXTURES_DIRECTORY});20 });21 t.true(isTerminated);22 t.is(signal, 'SIGTERM');23 t.true(timedOut);53 unmodified linesmodified:test/transform/encoding-final.js+3 added-3 removed
2 unmodified lines3 import {promisify} from 'node:util';4 import test from 'ava';5 import getStream from 'get-stream';6 import {execa, execaSync} from '../../index.js';7-import {setFixtureDir, FIXTURES_DIR} from '../helpers/fixtures-dir.js';7+import {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';8 import {fullStdio} from '../helpers/stdio.js';9 import {foobarString, foobarUint8Array, foobarHex} from '../helpers/input.js';10 11 const pExec = promisify(exec);12 13-setFixtureDir();13+setFixtureDirectory();14 15 const checkEncoding = async (t, encoding, fdNumber, execaMethod) => {16 const {stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`, STRING_TO_ENCODE], {...fullStdio, encoding});17 compareValues(t, stdio[fdNumber], encoding);8 unmodified lines26 if (fdNumber === 3) {27 return;28 }29 30- const {stdout, stderr} = await pExec(`node noop-fd.js ${fdNumber} ${STRING_TO_ENCODE}`, {encoding, cwd: FIXTURES_DIR});30+ const {stdout, stderr} = await pExec(`node noop-fd.js ${fdNumber} ${STRING_TO_ENCODE}`, {encoding, cwd: FIXTURES_DIRECTORY});31 compareValues(t, fdNumber === 1 ? stdout : stderr, encoding);32 };33 34 const compareValues = (t, value, encoding) => {95 unmodified linesmodified:test/transform/encoding-ignored.js+2 added-2 removed
1 import process from 'node:process';2 import test from 'ava';3 import {execa, execaSync} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {outputObjectGenerator, addNoopGenerator} from '../helpers/generator.js';6 import {foobarObject} from '../helpers/input.js';7 8-setFixtureDir();8+setFixtureDirectory();9 10 const testObjectMode = async (t, addNoopTransform, execaMethod) => {11 const {stdout} = await execaMethod('noop.js', {12 stdout: addNoopGenerator(outputObjectGenerator(), addNoopTransform, true),80 unmodified linesmodified:test/transform/encoding-multibyte.js+10 added-4 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {noopGenerator, getOutputsGenerator, addNoopGenerator} from '../helpers/generator.js';5-import {multibyteChar, multibyteString, multibyteUint8Array, breakingLength, brokenSymbol} from '../helpers/encoding.js';5+import {6+ multibyteChar,7+ multibyteString,8+ multibyteUint8Array,9+ breakingLength,10+ brokenSymbol,11+} from '../helpers/encoding.js';12 7-setFixtureDir();13+setFixtureDirectory();14 15 const foobarArray = ['fo', 'ob', 'ar', '..'];16 17 const testMultibyteCharacters = async (t, objectMode, addNoopTransform, execaMethod) => {3 unmodified lines21 });22 if (objectMode) {23 t.deepEqual(stdout, foobarArray);24 } else {19- t.is(stdout, btoa(foobarArray.join('')));25+ t.is(stdout, Buffer.from(foobarArray.join('')).toString('base64'));26 }27 };28 29 test('Handle multibyte characters', testMultibyteCharacters, false, false, execa);50 unmodified linesmodified:test/transform/encoding-transform.js+8 added-3 removed
1 import {Buffer} from 'node:buffer';2 import test from 'ava';3 import {execa, execaSync} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {getStdio} from '../helpers/stdio.js';6-import {foobarString, foobarUint8Array, foobarBuffer, foobarObject} from '../helpers/input.js';6+import {7+ foobarString,8+ foobarUint8Array,9+ foobarBuffer,10+ foobarObject,11+} from '../helpers/input.js';12 import {noopGenerator, getOutputGenerator} from '../helpers/generator.js';13 9-setFixtureDir();14+setFixtureDirectory();15 16 const getTypeofGenerator = lines => (objectMode, binary) => ({17 * transform(line) {18 lines.push(Object.prototype.toString.call(line));159 unmodified linesmodified:test/transform/generator-all.js+23 added-5 removed
1 import {Buffer} from 'node:buffer';2 import test from 'ava';3 import {execa, execaSync} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {foobarObject} from '../helpers/input.js';6 import {7 outputObjectGenerator,8 uppercaseGenerator,9 uppercaseBufferGenerator,10 } from '../helpers/generator.js';11 12-setFixtureDir();12+setFixtureDirectory();13 14 const textEncoder = new TextEncoder();15 16 const getAllStdioOption = (stdioOption, encoding, objectMode) => {48 unmodified lines65 lines,66 stripFinalNewline: false,67 });68 69- const stdoutOutput = getStdoutStderrOutput({output: 'std\nout\n', stdioOption: stdoutOption, encoding, objectMode, lines});69+ const stdoutOutput = getStdoutStderrOutput({70+ output: 'std\nout\n',71+ stdioOption: stdoutOption,72+ encoding,73+ objectMode,74+ lines,75+ });76 t.deepEqual(stdout, stdoutOutput);71- const stderrOutput = getStdoutStderrOutput({output: 'std\nerr\n', stdioOption: stderrOption, encoding, objectMode, lines});77+ const stderrOutput = getStdoutStderrOutput({78+ output: 'std\nerr\n',79+ stdioOption: stderrOption,80+ encoding,81+ objectMode,82+ lines,83+ });84 t.deepEqual(stderr, stderrOutput);73- const allOutput = getAllOutput({stdoutOutput, stderrOutput, encoding, objectMode, lines});85+ const allOutput = getAllOutput({86+ stdoutOutput,87+ stderrOutput,88+ encoding,89+ objectMode,90+ lines,91+ });92 if (Array.isArray(all) && Array.isArray(allOutput)) {93 t.deepEqual([...all].sort(), [...allOutput].sort());94 } else {95 t.deepEqual(all, allOutput);147 unmodified linesmodified:test/transform/generator-error.js+2 added-2 removed
2 unmodified lines3 import {execa, execaSync} from '../../index.js';4 import {foobarString} from '../helpers/input.js';5 import {noopGenerator, infiniteGenerator, convertTransformToFinal} from '../helpers/generator.js';6 import {generatorsMap} from '../helpers/map.js';7-import {setFixtureDir} from '../helpers/fixtures-dir.js';7+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';8 9-setFixtureDir();9+setFixtureDirectory();10 11 const assertProcessError = async (t, type, execaMethod, getSubprocess) => {12 const cause = new Error(foobarString);13 const transform = generatorsMap[type].throwing(cause)();76 unmodified linesmodified:test/transform/generator-final.js+2 added-2 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3 import {foobarString} from '../helpers/input.js';4 import {getOutputAsyncGenerator, getOutputGenerator, convertTransformToFinal} from '../helpers/generator.js';5-import {setFixtureDir} from '../helpers/fixtures-dir.js';5+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6 7-setFixtureDir();7+setFixtureDirectory();8 9 const testGeneratorFinal = async (t, fixtureName, execaMethod) => {10 const {stdout} = await execaMethod(fixtureName, {stdout: convertTransformToFinal(getOutputGenerator(foobarString)(), true)});11 t.is(stdout, foobarString);24 unmodified linesmodified:test/transform/generator-input.js+2 added-2 removed
1 import {Buffer} from 'node:buffer';2 import test from 'ava';3 import {execa, execaSync} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {getStdio} from '../helpers/stdio.js';6 import {7 foobarString,8 foobarUppercase,4 unmodified lines13 foobarObjectString,14 } from '../helpers/input.js';15 import {generatorsMap} from '../helpers/map.js';16 17-setFixtureDir();17+setFixtureDirectory();18 19 const getInputObjectMode = (objectMode, addNoopTransform, type) => objectMode20 ? {21 input: [foobarObject],137 unmodified linesmodified:test/transform/generator-main.js+2 added-2 removed
11 unmodified lines12 suffix,13 } from '../helpers/generator.js';14 import {generatorsMap} from '../helpers/map.js';15 import {defaultHighWaterMark} from '../helpers/stream.js';16-import {setFixtureDir} from '../helpers/fixtures-dir.js';16+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';17 import {maxBuffer, assertErrorMessage} from '../helpers/max-buffer.js';18 19-setFixtureDir();19+setFixtureDirectory();20 21 const repeatCount = defaultHighWaterMark * 3;22 23 const writerGenerator = function * () {162 unmodified linesmodified:test/transform/generator-mixed.js+2 added-2 removed
2 unmodified lines3 import test from 'ava';4 import getStream from 'get-stream';5 import tempfile from 'tempfile';6 import {execa, execaSync} from '../../index.js';7-import {setFixtureDir} from '../helpers/fixtures-dir.js';7+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';8 import {foobarString, foobarUppercase, foobarUint8Array} from '../helpers/input.js';9 import {uppercaseGenerator} from '../helpers/generator.js';10 import {uppercaseBufferDuplex} from '../helpers/duplex.js';11 import {uppercaseBufferWebTransform} from '../helpers/web-transform.js';12 import {generatorsMap} from '../helpers/map.js';13 14-setFixtureDir();14+setFixtureDirectory();15 16 const testInputOption = async (t, type, execaMethod) => {17 const {stdout} = await execaMethod('stdin-fd.js', ['0'], {stdin: generatorsMap[type].uppercase(), input: foobarUint8Array});18 t.is(stdout, foobarUppercase);86 unmodified linesmodified:test/transform/generator-output.js+2 added-2 removed
1 import test from 'ava';2 import getStream, {getStreamAsArray} from 'get-stream';3 import {execa, execaSync} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {getStdio} from '../helpers/stdio.js';6 import {foobarString, foobarUppercase, foobarObject} from '../helpers/input.js';7 import {generatorsMap} from '../helpers/map.js';8 9-setFixtureDir();9+setFixtureDirectory();10 11 const getOutputObjectMode = (objectMode, addNoopTransform, type, binary) => objectMode12 ? {13 generators: generatorsMap[type].addNoop(generatorsMap[type].outputObject(), addNoopTransform, objectMode, binary),248 unmodified linesmodified:test/transform/generator-return.js+2 added-2 removed
1 import {Buffer} from 'node:buffer';2 import test from 'ava';3 import {execa, execaSync} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {foobarString, foobarUint8Array} from '../helpers/input.js';6 import {getOutputGenerator, convertTransformToFinal} from '../helpers/generator.js';7 8-setFixtureDir();8+setFixtureDirectory();9 10 // eslint-disable-next-line max-params11 const testGeneratorReturnType = async (t, input, encoding, reject, objectMode, final, execaMethod) => {12 const fixtureName = reject ? 'noop-fd.js' : 'noop-fail.js';138 unmodified linesmodified:test/transform/normalize-transform.js+2 added-2 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {foobarString, foobarUppercase, foobarUint8Array} from '../helpers/input.js';5 import {casedSuffix} from '../helpers/generator.js';6 import {generatorsMap} from '../helpers/map.js';7 8-setFixtureDir();8+setFixtureDirectory();9 10 const testAppendInput = async (t, reversed, type, execaMethod) => {11 const stdin = [foobarUint8Array, generatorsMap[type].uppercase(), generatorsMap[type].append()];12 const reversedStdin = reversed ? stdin.reverse() : stdin;43 unmodified linesmodified:test/transform/split-binary.js+2 added-2 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {getOutputsGenerator, resultGenerator} from '../helpers/generator.js';5 import {6 simpleFull,7 simpleChunks,7 unmodified lines15 simpleLines,16 noNewlinesChunks,17 } from '../helpers/lines.js';18 19-setFixtureDir();19+setFixtureDirectory();20 21 // eslint-disable-next-line max-params22 const testBinaryOption = async (t, binary, input, expectedLines, expectedOutput, objectMode, preserveNewlines, encoding, execaMethod) => {23 const lines = [];72 unmodified linesmodified:test/transform/split-lines.js+2 added-2 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {getStdio} from '../helpers/stdio.js';5 import {getOutputsGenerator, resultGenerator} from '../helpers/generator.js';6 import {7 singleFull,7 unmodified lines15 noNewlinesFull,16 noNewlinesChunks,17 } from '../helpers/lines.js';18 19-setFixtureDir();19+setFixtureDirectory();20 21 const windowsFull = 'aaa\r\nbbb\r\nccc';22 const windowsFullEnd = `${windowsFull}\r\n`;23 const windowsChunks = [windowsFull];151 unmodified linesmodified:test/transform/split-newline.js+2 added-2 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {getOutputsGenerator, noopGenerator, noopAsyncGenerator} from '../helpers/generator.js';5 import {singleFull, singleFullEnd} from '../helpers/lines.js';6 7-setFixtureDir();7+setFixtureDirectory();8 9 const singleFullEndWindows = `${singleFull}\r\n`;10 const mixedNewlines = '.\n.\r\n.\n.\r\n.\n';11 26 unmodified linesmodified:test/transform/split-transform.js+8 added-3 removed
1 import test from 'ava';2 import {execa, execaSync} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {getOutputsGenerator, resultGenerator} from '../helpers/generator.js';5-import {foobarString, foobarUint8Array, foobarObject, foobarObjectString} from '../helpers/input.js';5+import {6+ foobarString,7+ foobarUint8Array,8+ foobarObject,9+ foobarObjectString,10+} from '../helpers/input.js';11 7-setFixtureDir();12+setFixtureDirectory();13 14 const resultUint8ArrayGenerator = function * (lines, chunk) {15 lines.push(chunk);16 yield new TextEncoder().encode(chunk);67 unmodified linesmodified:test/transform/validate.js+2 added-2 removed
1 import {Buffer} from 'node:buffer';2 import test from 'ava';3 import {execa, execaSync} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {getStdio} from '../helpers/stdio.js';6 import {foobarUint8Array, foobarBuffer, foobarObject} from '../helpers/input.js';7 import {serializeGenerator, getOutputGenerator, convertTransformToFinal} from '../helpers/generator.js';8 9-setFixtureDir();9+setFixtureDirectory();10 11 const getMessage = input => {12 if (input === null || input === undefined) {13 return 'not be called at all';82 unmodified linesmodified:test/verbose/complete.js+2 added-2 removed
1 import {stripVTControlCharacters} from 'node:util';2 import test from 'ava';3 import {execa} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {foobarString} from '../helpers/input.js';6 import {parentExecaAsync, parentExecaSync} from '../helpers/nested.js';7 import {8 runErrorSubprocessAsync,10 unmodified lines19 fdShortOption,20 fdFullOption,21 } from '../helpers/verbose.js';22 23-setFixtureDir();23+setFixtureDirectory();24 25 const testPrintCompletion = async (t, verbose, execaMethod) => {26 const {stderr} = await execaMethod('noop.js', [foobarString], {verbose});27 t.is(getCompletionLine(stderr), `${testTimestamp} [0] √ (done in 0ms)`);80 unmodified linesmodified:test/verbose/error.js+2 added-2 removed
1 import test from 'ava';2 import {red} from 'yoctocolors';3 import {execa} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {foobarString} from '../helpers/input.js';6 import {parentExeca, parentExecaAsync, parentExecaSync} from '../helpers/nested.js';7 import {8 QUOTE,9 unmodified lines18 fdShortOption,19 fdFullOption,20 } from '../helpers/verbose.js';21 22-setFixtureDir();22+setFixtureDirectory();23 24 const parentExecaFail = parentExeca.bind(undefined, 'nested-fail.js');25 26 const testPrintError = async (t, verbose, execaMethod) => {119 unmodified linesmodified:test/verbose/info.js+2 added-2 removed
1 import test from 'ava';2-import {setFixtureDir} from '../helpers/fixtures-dir.js';2+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';3 import {execa, execaSync} from '../../index.js';4 import {foobarString} from '../helpers/input.js';5 import {parentExecaAsync, parentExecaSync} from '../helpers/nested.js';6 import {3 unmodified lines10 getNormalizedLines,11 testTimestamp,12 } from '../helpers/verbose.js';13 14-setFixtureDir();14+setFixtureDirectory();15 16 const testVerboseGeneral = async (t, execaMethod) => {17 const {all} = await execaMethod('verbose-script.js', {env: {NODE_DEBUG: 'execa'}, all: true});18 t.deepEqual(getNormalizedLines(all), [26 unmodified linesmodified:test/verbose/log.js+2 added-2 removed
1 import {stripVTControlCharacters} from 'node:util';2 import test from 'ava';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {foobarString} from '../helpers/input.js';5 import {parentExecaAsync, parentExecaSync} from '../helpers/nested.js';6 7-setFixtureDir();7+setFixtureDirectory();8 9 const testNoStdout = async (t, verbose, execaMethod) => {10 const {stdout} = await execaMethod('noop.js', [foobarString], {verbose, stdio: 'inherit'});11 t.is(stdout, foobarString);16 unmodified linesmodified:test/verbose/output-buffer.js+14 added-4 removed
1 import test from 'ava';2-import {setFixtureDir} from '../helpers/fixtures-dir.js';2+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';3 import {foobarString, foobarUppercase} from '../helpers/input.js';4 import {parentExeca, parentExecaAsync, parentExecaSync} from '../helpers/nested.js';5-import {getOutputLine, testTimestamp, fdFullOption, fdStderrFullOption} from '../helpers/verbose.js';5+import {6+ getOutputLine,7+ testTimestamp,8+ fdFullOption,9+ fdStderrFullOption,10+} from '../helpers/verbose.js';11 7-setFixtureDir();12+setFixtureDirectory();13 14 const testPrintOutputNoBuffer = async (t, verbose, buffer, execaMethod) => {15 const {stderr} = await execaMethod('noop.js', [foobarString], {verbose, buffer});16 t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);16 unmodified lines33 test('Does not print stdout, buffer: false, different fd, sync', testPrintOutputNoBufferFalse, false, parentExecaSync);34 test('Does not print stdout, buffer: false, different fd, fd-specific buffer, sync', testPrintOutputNoBufferFalse, {stdout: false}, parentExecaSync);35 36 const testPrintOutputNoBufferTransform = async (t, buffer, isSync) => {32- const {stderr} = await parentExeca('nested-transform.js', 'noop.js', [foobarString], {verbose: 'full', buffer, type: 'generator', isSync});37+ const {stderr} = await parentExeca('nested-transform.js', 'noop.js', [foobarString], {38+ verbose: 'full',39+ buffer,40+ type: 'generator',41+ isSync,42+ });43 t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarUppercase}`);44 };45 46 test('Prints stdout, buffer: false, transform', testPrintOutputNoBufferTransform, false, false);3 unmodified linesmodified:test/verbose/output-enable.js+8 added-3 removed
1 import test from 'ava';2 import {red} from 'yoctocolors';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {foobarString} from '../helpers/input.js';5 import {fullStdio} from '../helpers/stdio.js';6-import {nestedExecaAsync, parentExeca, parentExecaAsync, parentExecaSync} from '../helpers/nested.js';6 import {7+ nestedExecaAsync,8+ parentExeca,9+ parentExecaAsync,10+ parentExecaSync,11+} from '../helpers/nested.js';12+import {13 runErrorSubprocessAsync,14 runErrorSubprocessSync,15 getOutputLine,16 getOutputLines,8 unmodified lines25 fd3ShortOption,26 fd3FullOption,27 } from '../helpers/verbose.js';28 24-setFixtureDir();29+setFixtureDirectory();30 31 const testPrintOutput = async (t, verbose, fdNumber, execaMethod) => {32 const {stderr} = await execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], {verbose});33 t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);113 unmodified linesmodified:test/verbose/output-mixed.js+2 added-2 removed
1 import {inspect} from 'node:util';2 import test from 'ava';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {foobarString, foobarObject} from '../helpers/input.js';5 import {simpleFull, noNewlinesChunks} from '../helpers/lines.js';6 import {parentExeca, parentExecaAsync, parentExecaSync} from '../helpers/nested.js';7 import {getOutputLine, getOutputLines, testTimestamp} from '../helpers/verbose.js';8 9-setFixtureDir();9+setFixtureDirectory();10 11 const testLines = async (t, lines, stripFinalNewline, execaMethod) => {12 const {stderr} = await execaMethod('noop-fd.js', ['1', simpleFull], {verbose: 'full', lines, stripFinalNewline});13 t.deepEqual(getOutputLines(stderr), noNewlinesChunks.map(line => `${testTimestamp} [0] ${line}`));44 unmodified linesmodified:test/verbose/output-noop.js+2 added-2 removed
1 import {rm, readFile} from 'node:fs/promises';2 import test from 'ava';3 import tempfile from 'tempfile';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {foobarString} from '../helpers/input.js';6 import {parentExeca, parentExecaAsync, parentExecaSync} from '../helpers/nested.js';7 import {getOutputLine, testTimestamp} from '../helpers/verbose.js';8 9-setFixtureDir();9+setFixtureDirectory();10 11 const testNoOutputOptions = async (t, fixtureName, options = {}) => {12 const {stderr} = await parentExeca(fixtureName, 'noop.js', [foobarString], {verbose: 'full', ...options});13 t.is(getOutputLine(stderr), undefined);44 unmodified linesmodified:test/verbose/output-pipe.js+10 added-5 removed
1 import test from 'ava';2 import {execa} from '../../index.js';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {foobarString} from '../helpers/input.js';5 import {parentExeca} from '../helpers/nested.js';6-import {getOutputLine, getOutputLines, testTimestamp, getVerboseOption} from '../helpers/verbose.js';6+import {7+ getOutputLine,8+ getOutputLines,9+ testTimestamp,10+ getVerboseOption,11+} from '../helpers/verbose.js';12 8-setFixtureDir();13+setFixtureDirectory();14 15 const testPipeOutput = async (t, fixtureName, sourceVerbose, destinationVerbose) => {16 const {stderr} = await execa(`nested-pipe-${fixtureName}.js`, [17 JSON.stringify(getVerboseOption(sourceVerbose, 'full')),22 unmodified lines40 test('Does not print stdout if neither verbose with .pipe("file")', testPipeOutput, 'file', false, false);41 test('Does not print stdout if neither verbose with .pipe`command`', testPipeOutput, 'script', false, false);42 test('Does not print stdout if neither verbose with .pipe(subprocess)', testPipeOutput, 'subprocesses', false, false);43 39-const testPrintOutputFixture = async (t, fixtureName, ...args) => {40- const {stderr} = await parentExeca(fixtureName, 'noop.js', [foobarString, ...args], {verbose: 'full'});44+const testPrintOutputFixture = async (t, fixtureName, ...commandArguments) => {45+ const {stderr} = await parentExeca(fixtureName, 'noop.js', [foobarString, ...commandArguments], {verbose: 'full'});46 t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);47 };48 49 test('Prints stdout, .pipe(stream) + .unpipe()', testPrintOutputFixture, 'nested-pipe-stream.js', 'true');1 unmodified linemodified:test/verbose/output-progressive.js+2 added-2 removed
1 import {on} from 'node:events';2 import test from 'ava';3-import {setFixtureDir} from '../helpers/fixtures-dir.js';3+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4 import {foobarString} from '../helpers/input.js';5 import {parentExeca, parentExecaAsync, parentExecaSync} from '../helpers/nested.js';6 import {getOutputLine, getOutputLines, testTimestamp} from '../helpers/verbose.js';7 8-setFixtureDir();8+setFixtureDirectory();9 10 test('Prints stdout one line at a time', async t => {11 const subprocess = parentExecaAsync('noop-progressive.js', [foobarString], {verbose: 'full'});12 46 unmodified linesmodified:test/verbose/start.js+2 added-2 removed
1 import test from 'ava';2 import {red} from 'yoctocolors';3 import {execa} from '../../index.js';4-import {setFixtureDir} from '../helpers/fixtures-dir.js';4+import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5 import {foobarString} from '../helpers/input.js';6 import {parentExecaAsync, parentExecaSync, parentWorker} from '../helpers/nested.js';7 import {8 QUOTE,9 unmodified lines18 fdShortOption,19 fdFullOption,20 } from '../helpers/verbose.js';21 22-setFixtureDir();22+setFixtureDirectory();23 24 const testPrintCommand = async (t, verbose, execaMethod) => {25 const {stderr} = await execaMethod('noop.js', [foobarString], {verbose});26 t.is(getCommandLine(stderr), `${testTimestamp} [0] $ noop.js ${foobarString}`);96 unmodified linesmodified:test-d/arguments/options.test-d.ts+6 added-1 removed
1 import * as process from 'node:process';2 import {expectError, expectAssignable, expectNotAssignable} from 'tsd';3-import {execa, execaSync, type Options, type SyncOptions} from '../../index.js';3+import {4+ execa,5+ execaSync,6+ type Options,7+ type SyncOptions,8+} from '../../index.js';9 10 const fileUrl = new URL('file:///test');11 12 expectAssignable<Options>({cleanup: false});185 unmodified linesmodified:test-d/methods/command.test-d.ts+7 added-1 removed
1 import {expectType, expectError, expectAssignable} from 'tsd';2-import {execaCommand, execaCommandSync, type ExecaResult, type ExecaSubprocess, type ExecaSyncResult} from '../../index.js';2+import {3+ execaCommand,4+ execaCommandSync,5+ type ExecaResult,6+ type ExecaSubprocess,7+ type ExecaSyncResult,8+} from '../../index.js';9 10 const fileUrl = new URL('file:///test');11 const stringArray = ['foo', 'bar'] as const;12 88 unmodified linesmodified:test-d/methods/node.test-d.ts+1 added-1 removed
1-import {expectType, expectError, expectAssignable, expectNotAssignable} from 'tsd';1+import {expectType, expectError, expectAssignable} from 'tsd';2 import {execaNode, type ExecaResult, type ExecaSubprocess} from '../../index.js';3 4 const fileUrl = new URL('file:///test');5 const stringArray = ['foo', 'bar'] as const;58 unmodified linesmodified:test-d/return/ignore-option.test-d.ts+12 added-2 removed
1 import {type Readable, type Writable} from 'node:stream';2 import {expectType, expectError} from 'tsd';3-import {execa, execaSync, type ExecaError, type ExecaSyncError} from '../../index.js';3+import {4+ execa,5+ execaSync,6+ type ExecaError,7+ type ExecaSyncError,8+} from '../../index.js';9 5-const ignoreAnyPromise = execa('unicorns', {stdin: 'ignore', stdout: 'ignore', stderr: 'ignore', all: true});10+const ignoreAnyPromise = execa('unicorns', {11+ stdin: 'ignore',12+ stdout: 'ignore',13+ stderr: 'ignore',14+ all: true,15+});16 expectType<null>(ignoreAnyPromise.stdin);17 expectType<null>(ignoreAnyPromise.stdio[0]);18 expectType<null>(ignoreAnyPromise.stdout);19 expectType<null>(ignoreAnyPromise.stdio[1]);134 unmodified linesmodified:test-d/return/ignore-other.test-d.ts+6 added-1 removed
1 import * as process from 'node:process';2 import {expectType} from 'tsd';3-import {execa, execaSync, type ExecaError, type ExecaSyncError} from '../../index.js';3+import {4+ execa,5+ execaSync,6+ type ExecaError,7+ type ExecaSyncError,8+} from '../../index.js';9 10 const inheritStdoutResult = await execa('unicorns', {stdout: 'inherit', all: true});11 expectType<undefined>(inheritStdoutResult.stdout);12 expectType<string>(inheritStdoutResult.stderr);146 unmodified linesmodified:test-d/return/lines-main.test-d.ts+6 added-1 removed
1 import {expectType} from 'tsd';2-import {execa, execaSync, type ExecaError, type ExecaSyncError} from '../../index.js';2+import {3+ execa,4+ execaSync,5+ type ExecaError,6+ type ExecaSyncError,7+} from '../../index.js';8 9 const linesResult = await execa('unicorns', {lines: true, all: true});10 expectType<string[]>(linesResult.stdout);11 expectType<string[]>(linesResult.stdio[1]);62 unmodified linesmodified:test-d/return/no-buffer-main.test-d.ts+6 added-1 removed
1 import type {Readable, Writable} from 'node:stream';2 import {expectType, expectError} from 'tsd';3-import {execa, execaSync, type ExecaError, type ExecaSyncError} from '../../index.js';3+import {4+ execa,5+ execaSync,6+ type ExecaError,7+ type ExecaSyncError,8+} from '../../index.js';9 10 const noBufferPromise = execa('unicorns', {buffer: false, all: true});11 expectType<Writable>(noBufferPromise.stdin);12 expectType<Writable>(noBufferPromise.stdio[0]);33 unmodified linesmodified:test-d/return/result-all.test-d.ts+6 added-1 removed
1 import {expectType} from 'tsd';2-import {execa, execaSync, type ExecaError, type ExecaSyncError} from '../../index.js';2+import {3+ execa,4+ execaSync,5+ type ExecaError,6+ type ExecaSyncError,7+} from '../../index.js';8 9 const allResult = await execa('unicorns', {all: true});10 expectType<string>(allResult.all);11 20 unmodified linesmodified:test-d/return/result-stdio.test-d.ts+6 added-1 removed
1 import {Readable, Writable} from 'node:stream';2 import {expectType} from 'tsd';3-import {execa, execaSync, type ExecaError, type ExecaSyncError} from '../../index.js';3+import {4+ execa,5+ execaSync,6+ type ExecaError,7+ type ExecaSyncError,8+} from '../../index.js';9 10 const unicornsResult = await execa('unicorns', {all: true});11 expectType<undefined>(unicornsResult.stdio[0]);12 expectType<string>(unicornsResult.stdout);112 unmodified linesmodified:test-d/stdio/direction.test-d.ts+6 added-1 removed
1 import {Readable, Writable} from 'node:stream';2 import {expectError, expectAssignable, expectNotAssignable} from 'tsd';3-import {execa, execaSync, type StdioOption, type StdioOptionSync} from '../../index.js';3+import {4+ execa,5+ execaSync,6+ type StdioOption,7+ type StdioOptionSync,8+} from '../../index.js';9 10 await execa('unicorns', {stdio: [new Readable(), 'pipe', 'pipe']});11 execaSync('unicorns', {stdio: [new Readable(), 'pipe', 'pipe']});12 await execa('unicorns', {stdio: [[new Readable()], ['pipe'], ['pipe']]});27 unmodified linesmodified:test-d/pipe.test-d.ts+6 added-1 removed
1 import {createWriteStream} from 'node:fs';2 import {expectType, expectNotType, expectError} from 'tsd';3-import {execa, execaSync, $, type ExecaResult} from '../index.js';3+import {4+ execa,5+ execaSync,6+ $,7+ type ExecaResult,8+} from '../index.js';9 10 const fileUrl = new URL('file:///test');11 const stringArray = ['foo', 'bar'] as const;12 const pipeOptions = {from: 'stderr', to: 'fd3', all: true} as const;242 unmodified linesmodified:types/methods/script.d.ts+10 added-5 removed
1-import type {CommonOptions, Options, SyncOptions, StricterOptions} from '../arguments/options';1+import type {2+ CommonOptions,3+ Options,4+ SyncOptions,5+ StricterOptions,6+} from '../arguments/options';7 import type {ExecaSyncResult} from '../return/result';8 import type {ExecaSubprocess} from '../subprocess/subprocess';9 import type {TemplateString} from './template';10 5 unmodified lines16 <NewOptionsType extends Options = {}>(17 file: string | URL,18 arguments?: readonly string[],19 options?: NewOptionsType,15- ): ExecaSubprocess<OptionsType & NewOptionsType>;20+ ): ExecaSubprocess<StricterOptions<OptionsType & NewOptionsType, Options>>;21 22 <NewOptionsType extends Options = {}>(23 file: string | URL,24 options?: NewOptionsType,20- ): ExecaSubprocess<OptionsType & NewOptionsType>;25+ ): ExecaSubprocess<StricterOptions<OptionsType & NewOptionsType, Options>>;26 };27 28 type ExecaScriptSync<OptionsType extends CommonOptions> = {29 <NewOptionsType extends SyncOptions = {}>(options: NewOptionsType): ExecaScriptSync<OptionsType & NewOptionsType>;3 unmodified lines33 <NewOptionsType extends SyncOptions = {}>(34 file: string | URL,35 arguments?: readonly string[],36 options?: NewOptionsType,32- ): ExecaSyncResult<OptionsType & NewOptionsType>;37+ ): ExecaSyncResult<StricterOptions<OptionsType & NewOptionsType, SyncOptions>>;38 39 <NewOptionsType extends SyncOptions = {}>(40 file: string | URL,41 options?: NewOptionsType,37- ): ExecaSyncResult<OptionsType & NewOptionsType>;42+ ): ExecaSyncResult<StricterOptions<OptionsType & NewOptionsType, SyncOptions>>;43 };44 45 type ExecaScript<OptionsType extends CommonOptions> = {46 sync: ExecaScriptSync<OptionsType>;39 unmodified linesmodified:types/stdio/option.d.ts+6 added-1 removed
1 import type {CommonOptions} from '../arguments/options';2 import type {StdioOptionNormalizedArray} from './array';3-import type {StandardStreams, StdioOptionCommon, StdioOptionsArray, StdioOptionsProperty} from './type';3+import type {4+ StandardStreams,5+ StdioOptionCommon,6+ StdioOptionsArray,7+ StdioOptionsProperty,8+} from './type';9 10 // `options.stdin|stdout|stderr|stdio` for a given file descriptor11 export type FdStdioOption<12 FdNumber extends string,28 unmodified linesmodified:types/stdio/type.d.ts+13 added-2 removed
1 import type {Readable, Writable} from 'node:stream';2-import type {Not, And, Or, Unless, AndUnless} from '../utils';3-import type {GeneratorTransform, GeneratorTransformFull, DuplexTransform, WebTransform} from '../transform/normalize';2+import type {3+ Not,4+ And,5+ Or,6+ Unless,7+ AndUnless,8+} from '../utils';9+import type {10+ GeneratorTransform,11+ GeneratorTransformFull,12+ DuplexTransform,13+ WebTransform,14+} from '../transform/normalize';15 16 type IsStandardStream<FdNumber extends string> = FdNumber extends keyof StandardStreams ? true : false;17 18 export type StandardStreams = ['stdin', 'stdout', 'stderr'];151 unmodified linesmodified:types/subprocess/subprocess.d.ts+6 added-1 removed
2 unmodified lines3 import type {StdioOptionsArray} from '../stdio/type';4 import type {Options} from '../arguments/options';5 import type {ExecaResult} from '../return/result';6 import type {PipableSubprocess} from '../pipe';7-import type {ReadableOptions, WritableOptions, DuplexOptions, SubprocessAsyncIterable} from '../convert';7+import type {8+ ReadableOptions,9+ WritableOptions,10+ DuplexOptions,11+ SubprocessAsyncIterable,12+} from '../convert';13 import type {SubprocessStdioStream} from './stdout';14 import type {SubprocessStdioArray} from './stdio';15 import type {SubprocessAll} from './all';16 128 unmodified linesmodified:index.d.ts+8 added-1 removed
1-export type {StdinOption, StdinOptionSync, StdoutStderrOption, StdoutStderrOptionSync, StdioOption, StdioOptionSync} from './types/stdio/type';1+export type {2+ StdinOption,3+ StdinOptionSync,4+ StdoutStderrOption,5+ StdoutStderrOptionSync,6+ StdioOption,7+ StdioOptionSync,8+} from './types/stdio/type';9 export type {Options, SyncOptions} from './types/arguments/options';10 export type {ExecaResult, ExecaSyncResult} from './types/return/result';11 export type {ExecaResultPromise, ExecaSubprocess} from './types/subprocess/subprocess';12 /* eslint-disable import/extensions */7 unmodified linesmodified:package.json+1 added-1 removed
71 unmodified lines72 "path-key": "^4.0.0",73 "tempfile": "^5.0.0",74 "tsd": "^0.29.0",75 "which": "^4.0.0",76- "xo": "^0.56.0"76+ "xo": "^0.58.0"77 },78 "c8": {79 "reporter": [80 "text",20 unmodified lines