Improve `verbose` option (#962)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent 10fdc8b · Browse files · 13 files·+105 added−104 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
13 files+105 added−104 removed
- other:+105 added−104 removed
Provenance
- Commit
58beaa6- Tree
a560ef1- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
10fdc8b
13 files changed+105 added−104 removed
modified:lib/convert/loop.js+2 added-1 removed
24 unmodified lines252627282929303132333462 unmodified lines24 unmodified lines controller.abort(); }};
// Iterate over lines of `subprocess.stdout`, used by `result.stdout` + `lines: true` option// Iterate over lines of `subprocess.stdout`, used by `result.stdout` and the `verbose: 'full'` option.// Applies the `lines` and `encoding` options.export const iterateForResult = ({stream, onStreamEnd, lines, encoding, stripFinalNewline, allMixed}) => { const controller = new AbortController(); stopReadingOnStreamEnd(onStreamEnd, controller, stream); const objectMode = stream.readableObjectMode && !allMixed;62 unmodified linesmodified:lib/stdio/async.js+1 added-2 removed
51 unmodified lines52 };53 54 // Handle `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, after spawning, in async mode55 // When multiple input streams are used, we merge them to ensure the output stream ends only once each input stream has ended56-export const pipeOutputAsync = (subprocess, fileDescriptors, stdioState, controller) => {57- stdioState.subprocess = subprocess;56+export const pipeOutputAsync = (subprocess, fileDescriptors, controller) => {57 const inputStreamsGroups = {};58 59 for (const [fdNumber, {stdioItems, direction}] of Object.entries(fileDescriptors)) {60 for (const {stream} of stdioItems.filter(({type}) => TRANSFORM_TYPES.has(type))) {54 unmodified linesdeleted:lib/stdio/forward.js-16 removed
12345678910111213141516// Whether `subprocess.std*` will be setexport const willPipeFileDescriptor = stdioItems => PIPED_STDIO_VALUES.has(forwardStdio(stdioItems));
export const PIPED_STDIO_VALUES = new Set(['pipe', 'overlapped']);
// When the `std*: Iterable | WebStream | URL | filePath`, `input` or `inputFile` option is used, we pipe to `subprocess.std*`.// When the `std*: Array` option is used, we emulate some of the native values ('inherit', Node.js stream and file descriptor integer). To do so, we also need to pipe to `subprocess.std*`.// Therefore the `std*` options must be either `pipe` or `overlapped`. Other values do not set `subprocess.std*`.export const forwardStdio = stdioItems => { if (stdioItems.length > 1) { return stdioItems.some(({value}) => value === 'overlapped') ? 'overlapped' : 'pipe'; }
const [{type, value}] = stdioItems; return type === 'native' ? value : 'pipe';};modified:lib/stdio/generator.js+11 added-10 removed
5 unmodified lines6 import {pipeStreams} from './pipeline.js';7 import {isAsyncGenerator} from './type.js';8 import {getValidateTransformInput, getValidateTransformReturn} from './validate.js';9 10-export const getObjectMode = (stdioItems, optionName, direction, options) => {11- const transforms = getTransforms(stdioItems, optionName, direction, options);12- if (transforms.length === 0) {13- return false;14- }15-16- const {value: {readableObjectMode, writableObjectMode}} = transforms.at(-1);17- return direction === 'input' ? writableObjectMode : readableObjectMode;18-};19-10 export const normalizeTransforms = (stdioItems, optionName, direction, options) => [11 ...stdioItems.filter(({type}) => !TRANSFORM_TYPES.has(type)),12 ...getTransforms(stdioItems, optionName, direction, options),13 ];98 unmodified lines112 };113 114 const sortTransforms = (newTransforms, direction) => direction === 'input' ? newTransforms.reverse() : newTransforms;115 116+export const getObjectMode = (stdioItems, direction) => {117+ const lastTransform = stdioItems.findLast(({type}) => TRANSFORM_TYPES.has(type));118+ if (lastTransform === undefined) {119+ return false;120+ }121+122+ return direction === 'input'123+ ? lastTransform.value.writableObjectMode124+ : lastTransform.value.readableObjectMode;125+};126+127 /*128 Generators can be used to transform/filter standard streams.129 130 Generators have a simple syntax, yet allows all of the following:68 unmodified linesmodified:lib/stdio/handle.js+25 added-28 removed
1-import {handleStreamsVerbose} from '../verbose/output.js';1 import {getStdioItemType, isRegularUrl, isUnknownStdioString, FILE_TYPES} from './type.js';2 import {getStreamDirection} from './direction.js';3 import {normalizeStdio} from './option.js';4 import {handleNativeStream} from './native.js';5 import {handleInputOptions} from './input.js';6 import {normalizeTransforms, getObjectMode} from './generator.js';8-import {forwardStdio, willPipeFileDescriptor} from './forward.js';7 8 // Handle `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, before spawning, in async/sync mode9 export const handleInput = (addProperties, options, verboseInfo, isSync) => {12- const stdioState = {};10 const stdio = normalizeStdio(options, isSync);11 const fileDescriptors = stdio.map((stdioOption, fdNumber) =>15- getFileDescriptor({stdioOption, fdNumber, addProperties, options, isSync, stdioState, verboseInfo}));12+ getFileDescriptor({stdioOption, fdNumber, addProperties, options, isSync}));13 options.stdio = fileDescriptors.map(({stdioItems}) => forwardStdio(stdioItems));17- return {fileDescriptors, stdioState};14+ return fileDescriptors;15 };16 17 // We make sure passing an array with a single item behaves the same as passing that item without an array.18 // This is what users would expect.19 // For example, `stdout: ['ignore']` behaves the same as `stdout: 'ignore'`.23-const getFileDescriptor = ({stdioOption, fdNumber, addProperties, options, isSync, stdioState, verboseInfo}) => {20+const getFileDescriptor = ({stdioOption, fdNumber, addProperties, options, isSync}) => {21 const optionName = getOptionName(fdNumber);22 const {stdioItems: initialStdioItems, isStdioArray} = initializeStdioItems({stdioOption, fdNumber, options, optionName});23 const direction = getStreamDirection(initialStdioItems, fdNumber, optionName);24 const stdioItems = initialStdioItems.map(stdioItem => handleNativeStream({stdioItem, isStdioArray, fdNumber, direction, isSync}));28- const objectMode = getObjectMode(stdioItems, optionName, direction, options);29- validateFileObjectMode(stdioItems, objectMode);30- const normalizedStdioItems = normalizeStdioItems({stdioItems, fdNumber, optionName, addProperties, options, direction, stdioState, verboseInfo});31- return {direction, objectMode, stdioItems: normalizedStdioItems};25+ const normalizedStdioItems = normalizeTransforms(stdioItems, optionName, direction, options);26+ const objectMode = getObjectMode(normalizedStdioItems, direction);27+ validateFileObjectMode(normalizedStdioItems, objectMode);28+ const finalStdioItems = normalizedStdioItems.map(stdioItem => addStreamProperties(stdioItem, addProperties, direction, options));29+ return {direction, objectMode, stdioItems: finalStdioItems};30 };31 32 const getOptionName = fdNumber => KNOWN_OPTION_NAMES[fdNumber] ?? `stdio[${fdNumber}]`;33 const KNOWN_OPTION_NAMES = ['stdin', 'stdout', 'stderr'];60 unmodified lines94 throw new TypeError(`The \`${optionName}: { file: '...' }\` option must be used instead of \`${optionName}: '...'\`.`);95 }96 };97 100-const normalizeStdioItems = ({stdioItems, fdNumber, optionName, addProperties, options, direction, stdioState, verboseInfo}) => {101- const allStdioItems = addInternalStdioItems({stdioItems, fdNumber, optionName, options, stdioState, verboseInfo});102- const normalizedStdioItems = normalizeTransforms(allStdioItems, optionName, direction, options);103- return normalizedStdioItems.map(stdioItem => addStreamProperties(stdioItem, addProperties, direction, options));98+const validateFileObjectMode = (stdioItems, objectMode) => {99+ if (!objectMode) {100+ return;101+ }102+103+ const fileStdioItem = stdioItems.find(({type}) => FILE_TYPES.has(type));104+ if (fileStdioItem !== undefined) {105+ throw new TypeError(`The \`${fileStdioItem.optionName}\` option cannot use both files and transforms in objectMode.`);106+ }107 };108 106-const addInternalStdioItems = ({stdioItems, fdNumber, optionName, options, stdioState, verboseInfo}) => willPipeFileDescriptor(stdioItems)107- ? [108- ...stdioItems,109- ...handleStreamsVerbose({stdioItems, options, stdioState, verboseInfo, fdNumber, optionName}),110- ]111- : stdioItems;112-109 // Some `stdio` values require Execa to create streams.110 // For example, file paths create file read/write streams.111 // Those transformations are specified in `addProperties`, which is both direction-specific and type-specific.112 const addStreamProperties = (stdioItem, addProperties, direction, options) => ({113 ...stdioItem,114 ...addProperties[direction][stdioItem.type](stdioItem, options),115 });116 121-const validateFileObjectMode = (stdioItems, objectMode) => {122- if (!objectMode) {123- return;117+// When the `std*: Iterable | WebStream | URL | filePath`, `input` or `inputFile` option is used, we pipe to `subprocess.std*`.118+// When the `std*: Array` option is used, we emulate some of the native values ('inherit', Node.js stream and file descriptor integer). To do so, we also need to pipe to `subprocess.std*`.119+// Therefore the `std*` options must be either `pipe` or `overlapped`. Other values do not set `subprocess.std*`.120+const forwardStdio = stdioItems => {121+ if (stdioItems.length > 1) {122+ return stdioItems.some(({value}) => value === 'overlapped') ? 'overlapped' : 'pipe';123 }124 126- const fileStdioItem = stdioItems.find(({type}) => FILE_TYPES.has(type));127- if (fileStdioItem !== undefined) {128- throw new TypeError(`The \`${fileStdioItem.optionName}\` option cannot use both files and transforms in objectMode.`);129- }125+ const [{type, value}] = stdioItems;126+ return type === 'native' ? value : 'pipe';127 };modified:lib/stdio/output-sync.js+18 added-9 removed
1 import {writeFileSync} from 'node:fs';2+import {shouldLogOutput, logLinesSync} from '../verbose/output.js';3 import {joinToString, joinToUint8Array, bufferToUint8Array, isUint8Array, concatUint8Arrays} from './uint-array.js';4 import {getGenerators, runGeneratorsSync} from './generator.js';5 import {splitLinesSync} from './split.js';6 import {FILE_TYPES} from './type.js';7 8 // Apply `stdout`/`stderr` options, after spawning, in sync mode8-export const transformOutputSync = ({fileDescriptors, syncResult: {output}, options, isMaxBuffer}) => {9+export const transformOutputSync = ({fileDescriptors, syncResult: {output}, options, isMaxBuffer, verboseInfo}) => {10 if (output === null) {11 return {output: Array.from({length: 3})};12 }13 14 const state = {};15 const transformedOutput = output.map((result, fdNumber) =>15- transformOutputResultSync({result, fileDescriptors, fdNumber, state, isMaxBuffer}, options));16+ transformOutputResultSync({result, fileDescriptors, fdNumber, state, isMaxBuffer, verboseInfo}, options));17 return {output: transformedOutput, ...state};18 };19 19-const transformOutputResultSync = ({result, fileDescriptors, fdNumber, state, isMaxBuffer}, {buffer, encoding, lines, stripFinalNewline, maxBuffer}) => {20+const transformOutputResultSync = ({result, fileDescriptors, fdNumber, state, isMaxBuffer, verboseInfo}, {buffer, encoding, lines, stripFinalNewline, maxBuffer}) => {21 if (result === null) {22 return;23 }24 1 unmodified line26 const uint8ArrayResult = bufferToUint8Array(truncatedResult);27 const {stdioItems, objectMode} = fileDescriptors[fdNumber];28 const generators = getGenerators(stdioItems);29 const chunks = runOutputGeneratorsSync([uint8ArrayResult], generators, encoding, state);30+ const {31+ serializedResult,32+ finalResult = serializedResult,29- const {serializedResult, finalResult} = serializeChunks({chunks, objectMode, encoding, lines, stripFinalNewline});33+ } = serializeChunks({chunks, objectMode, encoding, lines, stripFinalNewline});34+35+ if (shouldLogOutput({stdioItems, encoding, verboseInfo, fdNumber})) {36+ const linesArray = splitLinesSync(serializedResult, false, objectMode);37+ logLinesSync(linesArray, verboseInfo);38+ }39+40 const returnedResult = buffer ? finalResult : undefined;41 42 try {43 if (state.error === undefined) {21 unmodified lines65 };66 67 const serializeChunks = ({chunks, objectMode, encoding, lines, stripFinalNewline}) => {68 if (objectMode) {59- return {finalResult: chunks};69+ return {serializedResult: chunks};70 }71 72 if (encoding === 'buffer') {63- const serializedResult = joinToUint8Array(chunks);64- return {serializedResult, finalResult: serializedResult};73+ return {serializedResult: joinToUint8Array(chunks)};74 }75 76 const serializedResult = joinToString(chunks, encoding);77 if (lines) {69- return {serializedResult, finalResult: splitLinesSync(serializedResult, !stripFinalNewline)};78+ return {serializedResult, finalResult: splitLinesSync(serializedResult, !stripFinalNewline, objectMode)};79 }80 72- return {serializedResult, finalResult: serializedResult};81+ return {serializedResult};82 };83 84 const writeToFiles = (serializedResult, stdioItems) => {85 for (const {type, path} of stdioItems) {33 unmodified linesmodified:lib/stdio/split.js+6 added-2 removed
1 unmodified line2 export const getSplitLinesGenerator = (binary, preserveNewlines, skipped, state) => binary || skipped3 ? undefined4 : initializeSplitLines(preserveNewlines, state);5 6-export const splitLinesSync = (string, preserveNewlines) => {6+export const splitLinesSync = (chunk, preserveNewlines, objectMode) => objectMode7+ ? chunk.flatMap(item => splitLinesItemSync(item, preserveNewlines))8+ : splitLinesItemSync(chunk, preserveNewlines);9+10+const splitLinesItemSync = (chunk, preserveNewlines) => {11 const {transform, final} = initializeSplitLines(preserveNewlines, {});8- return [...transform(string), ...final()];12+ return [...transform(chunk), ...final()];13 };14 15 const initializeSplitLines = (preserveNewlines, state) => {16 state.previousChunks = '';93 unmodified linesmodified:lib/stream/all.js+3 added-1 removed
5 unmodified lines6789101011121314151617181920212223247 unmodified lines5 unmodified lines ? mergeStreams([stdout, stderr].filter(Boolean)) : undefined;
// Read the contents of `subprocess.all` and|or wait for its completionexport const waitForAllStream = ({subprocess, encoding, buffer, maxBuffer, lines, stripFinalNewline, streamInfo}) => waitForSubprocessStream({export const waitForAllStream = ({subprocess, encoding, buffer, maxBuffer, lines, stripFinalNewline, verboseInfo, streamInfo}) => waitForSubprocessStream({ stream: subprocess.all, fdNumber: 1, encoding, buffer, maxBuffer: maxBuffer * 2, lines, isAll: true, allMixed: getAllMixed(subprocess), stripFinalNewline, verboseInfo, streamInfo,});
// When `subprocess.stdout` is in objectMode but not `subprocess.stderr` (or the opposite), we need to use both:7 unmodified linesmodified:lib/stream/resolve.js+5 added-4 removed
13 unmodified lines14 export const getSubprocessResult = async ({15 subprocess,16 options: {encoding, buffer, maxBuffer, lines, timeoutDuration: timeout, stripFinalNewline},17 context,18+ verboseInfo,19 fileDescriptors,20 originalStreams,21 controller,22 }) => {23 const exitPromise = waitForExit(subprocess);24 const streamInfo = {originalStreams, fileDescriptors, subprocess, exitPromise, propagating: false};25 25- const stdioPromises = waitForSubprocessStreams({subprocess, encoding, buffer, maxBuffer, lines, stripFinalNewline, streamInfo});26- const allPromise = waitForAllStream({subprocess, encoding, buffer, maxBuffer, lines, stripFinalNewline, streamInfo});26+ const stdioPromises = waitForSubprocessStreams({subprocess, encoding, buffer, maxBuffer, lines, stripFinalNewline, verboseInfo, streamInfo});27+ const allPromise = waitForAllStream({subprocess, encoding, buffer, maxBuffer, lines, stripFinalNewline, verboseInfo, streamInfo});28 const originalPromises = waitForOriginalStreams(originalStreams, subprocess, streamInfo);29 const customStreamsEndPromises = waitForCustomStreamsEnd(fileDescriptors, streamInfo);30 31 try {22 unmodified lines54 }55 };56 57 // Read the contents of `subprocess.std*` and|or wait for its completion57-const waitForSubprocessStreams = ({subprocess, encoding, buffer, maxBuffer, lines, stripFinalNewline, streamInfo}) =>58- subprocess.stdio.map((stream, fdNumber) => waitForSubprocessStream({stream, fdNumber, encoding, buffer, maxBuffer, lines, allMixed: false, stripFinalNewline, streamInfo}));58+const waitForSubprocessStreams = ({subprocess, encoding, buffer, maxBuffer, lines, stripFinalNewline, verboseInfo, streamInfo}) =>59+ subprocess.stdio.map((stream, fdNumber) => waitForSubprocessStream({stream, fdNumber, encoding, buffer, maxBuffer, lines, isAll: false, allMixed: false, stripFinalNewline, verboseInfo, streamInfo}));60 61 // Transforms replace `subprocess.std*`, which means they are not exposed to users.62 // However, we still want to wait for their completion.63 const waitForOriginalStreams = (originalStreams, subprocess, streamInfo) =>23 unmodified linesmodified:lib/stream/subprocess.js+9 added-3 removed
1 import {setImmediate} from 'node:timers/promises';2 import getStream, {getStreamAsArrayBuffer, getStreamAsArray, MaxBufferError} from 'get-stream';3 import {iterateForResult} from '../convert/loop.js';4 import {isArrayBuffer} from '../stdio/uint-array.js';5+import {shouldLogOutput, logLines} from '../verbose/output.js';6 import {waitForStream, isInputFileDescriptor} from './wait.js';7 7-export const waitForSubprocessStream = async ({stream, fdNumber, encoding, buffer, maxBuffer, lines, allMixed, stripFinalNewline, streamInfo}) => {8+export const waitForSubprocessStream = async ({stream, fdNumber, encoding, buffer, maxBuffer, lines, isAll, allMixed, stripFinalNewline, verboseInfo, streamInfo}) => {9 if (!stream) {10 return;11 }12 13 const onStreamEnd = waitForStream(stream, fdNumber, streamInfo);14 const [output] = await Promise.all([14- waitForDefinedStream({stream, onStreamEnd, fdNumber, encoding, buffer, maxBuffer, lines, allMixed, stripFinalNewline, streamInfo}),15+ waitForDefinedStream({stream, onStreamEnd, fdNumber, encoding, buffer, maxBuffer, lines, isAll, allMixed, stripFinalNewline, verboseInfo, streamInfo}),16 onStreamEnd,17 ]);18 return output;19 };20 20-const waitForDefinedStream = async ({stream, onStreamEnd, fdNumber, encoding, buffer, maxBuffer, lines, allMixed, stripFinalNewline, streamInfo}) => {21+const waitForDefinedStream = async ({stream, onStreamEnd, fdNumber, encoding, buffer, maxBuffer, lines, isAll, allMixed, stripFinalNewline, verboseInfo, streamInfo, streamInfo: {fileDescriptors}}) => {22 if (isInputFileDescriptor(streamInfo, fdNumber)) {23 return;24 }25 26+ if (!isAll && shouldLogOutput({stdioItems: fileDescriptors[fdNumber].stdioItems, encoding, verboseInfo, fdNumber})) {27+ const linesIterable = iterateForResult({stream, onStreamEnd, lines: true, encoding, stripFinalNewline: true, allMixed});28+ logLines(linesIterable, stream, verboseInfo);29+ }30+31 if (!buffer) {32 await resumeStream(stream);33 return;34 }49 unmodified linesmodified:lib/verbose/output.js+14 added-17 removed
1 import {inspect} from 'node:util';2 import {escapeLines} from '../arguments/escape.js';3 import {BINARY_ENCODINGS} from '../arguments/encoding.js';4-import {PIPED_STDIO_VALUES} from '../stdio/forward.js';4 import {TRANSFORM_TYPES} from '../stdio/generator.js';5 import {verboseLog} from './log.js';6 8-export const handleStreamsVerbose = ({stdioItems, options, stdioState, verboseInfo, fdNumber, optionName}) => shouldLogOutput({stdioItems, options, verboseInfo, fdNumber})9- ? [{10- type: 'generator',11- value: verboseGenerator.bind(undefined, {stdioState, fdNumber, verboseInfo}),12- optionName,13- }]14- : [];15-7 // `ignore` opts-out of `verbose` for a specific stream.8 // `ipc` cannot use piping.9 // `inherit` would result in double printing.10 // They can also lead to double printing when passing file descriptor integers or `process.std*`.11 // This only leaves with `pipe` and `overlapped`.21-const shouldLogOutput = ({stdioItems, options: {encoding}, verboseInfo: {verbose}, fdNumber}) => verbose === 'full'12+export const shouldLogOutput = ({stdioItems, encoding, verboseInfo: {verbose}, fdNumber}) => verbose === 'full'13 && !BINARY_ENCODINGS.has(encoding)14 && fdUsesVerbose(fdNumber)15 && (stdioItems.some(({type, value}) => type === 'native' && PIPED_STDIO_VALUES.has(value))16 || stdioItems.every(({type}) => TRANSFORM_TYPES.has(type)));3 unmodified lines20 // We could print `stdio[3+]` but it often is redirected to files and streams, with the same issue.21 // So we only print stdout and stderr.22 const fdUsesVerbose = fdNumber => fdNumber === 1 || fdNumber === 2;23 33-const verboseGenerator = function * ({stdioState, fdNumber, verboseInfo}, line) {34- if (!isPiping(stdioState, fdNumber)) {35- logOutput(line, verboseInfo);24+const PIPED_STDIO_VALUES = new Set(['pipe', 'overlapped']);25+26+export const logLines = async (linesIterable, stream, verboseInfo) => {27+ for await (const line of linesIterable) {28+ if (!isPipingStream(stream)) {29+ logLine(line, verboseInfo);30+ }31 }32+};33 38- yield line;34+export const logLinesSync = (linesArray, verboseInfo) => {35+ for (const line of linesArray) {36+ logLine(line, verboseInfo);37+ }38 };39 40 // When `subprocess.stdout|stderr.pipe()` is called, `verbose` becomes a noop.41 // This prevents the following problems:1 unmodified line43 // For example, `subprocess.stdout.pipe(process.stdin)` would print each line twice.44 // - When chaining subprocesses with `subprocess.pipe(otherSubprocess)`, only the last one should print its output.45 // Detecting whether `.pipe()` is impossible without monkey-patching it, so we use the following undocumented property.46 // This is not a critical behavior since changes of the following property would only make `verbose` more verbose.48-const isPiping = (stdioState, fdNumber) => stdioState.subprocess !== undefined && isPipingStream(stdioState.subprocess.stdio[fdNumber]);49-47 const isPipingStream = stream => stream._readableState.pipes.length > 0;48 49 // When `verbose` is `full`, print stdout|stderr53-const logOutput = (line, {verboseId}) => {50+const logLine = (line, {verboseId}) => {51 const lines = typeof line === 'string' ? line : inspect(line);52 const escapedLines = escapeLines(lines);53 const spacedLines = escapedLines.replaceAll('\t', ' '.repeat(TAB_SIZE));54 verboseLog(spacedLines, verboseId, 'output');4 unmodified linesmodified:lib/async.js+7 added-7 removed
14 unmodified lines15 import {getSubprocessResult} from './stream/resolve.js';16 import {mergePromise} from './promise.js';17 18 export const execaCoreAsync = (rawFile, rawArgs, rawOptions, createNested) => {19- const {file, args, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors, stdioState} = handleAsyncArguments(rawFile, rawArgs, rawOptions);20- const {subprocess, promise} = spawnSubprocessAsync({file, args, options, startTime, verboseInfo, command, escapedCommand, fileDescriptors, stdioState});19+ const {file, args, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors} = handleAsyncArguments(rawFile, rawArgs, rawOptions);20+ const {subprocess, promise} = spawnSubprocessAsync({file, args, options, startTime, verboseInfo, command, escapedCommand, fileDescriptors});21 subprocess.pipe = pipeToSubprocess.bind(undefined, {source: subprocess, sourcePromise: promise, boundOptions: {}, createNested});22 mergePromise(subprocess, promise);23 SUBPROCESS_OPTIONS.set(subprocess, {options, fileDescriptors});24 return subprocess;4 unmodified lines29 30 try {31 const {file, args, options: normalizedOptions} = handleOptions(rawFile, rawArgs, rawOptions);32 const options = handleAsyncOptions(normalizedOptions);33- const {fileDescriptors, stdioState} = handleInputAsync(options, verboseInfo);34- return {file, args, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors, stdioState};33+ const fileDescriptors = handleInputAsync(options, verboseInfo);34+ return {file, args, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors};35 } catch (error) {36 logEarlyResult(error, startTime, verboseInfo);37 throw error;38 }7 unmodified lines46 47 return {...options, timeoutDuration: timeout, signal: cancelSignal};48 };49 50-const spawnSubprocessAsync = ({file, args, options, startTime, verboseInfo, command, escapedCommand, fileDescriptors, stdioState}) => {50+const spawnSubprocessAsync = ({file, args, options, startTime, verboseInfo, command, escapedCommand, fileDescriptors}) => {51 let subprocess;52 try {53 subprocess = spawn(file, args, options);54 } catch (error) {3 unmodified lines58 const controller = new AbortController();59 setMaxListeners(Number.POSITIVE_INFINITY, controller.signal);60 61 const originalStreams = [...subprocess.stdio];62- pipeOutputAsync(subprocess, fileDescriptors, stdioState, controller);62+ pipeOutputAsync(subprocess, fileDescriptors, controller);63 cleanupOnExit(subprocess, options, controller);64 65 subprocess.kill = subprocessKill.bind(undefined, {kill: subprocess.kill.bind(subprocess), subprocess, options, controller});66 subprocess.all = makeAllStream(subprocess, options);10 unmodified lines77 errorInfo,78 [exitCode, signal],79 stdioResults,80 allResult,81- ] = await getSubprocessResult({subprocess, options, context, fileDescriptors, originalStreams, controller});81+ ] = await getSubprocessResult({subprocess, options, context, verboseInfo, fileDescriptors, originalStreams, controller});82 controller.abort();83 84 const stdio = stdioResults.map(stdioResult => stripNewline(stdioResult, options));85 const all = stripNewline(allResult, options);20 unmodified linesmodified:lib/sync.js+4 added-4 removed
8 unmodified lines9 import {getSyncExitResult} from './exit/code.js';10 11 export const execaCoreSync = (rawFile, rawArgs, rawOptions) => {12 const {file, args, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors} = handleSyncArguments(rawFile, rawArgs, rawOptions);13- const result = spawnSubprocessSync({file, args, options, command, escapedCommand, fileDescriptors, startTime});13+ const result = spawnSubprocessSync({file, args, options, command, escapedCommand, verboseInfo, fileDescriptors, startTime});14 return handleResult(result, verboseInfo, options);15 };16 17 const handleSyncArguments = (rawFile, rawArgs, rawOptions) => {2 unmodified lines20 try {21 const syncOptions = normalizeSyncOptions(rawOptions);22 const {file, args, options} = handleOptions(rawFile, rawArgs, syncOptions);23 validateSyncOptions(options);24- const {fileDescriptors} = handleInputSync(options, verboseInfo);24+ const fileDescriptors = handleInputSync(options, verboseInfo);25 return {file, args, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors};26 } catch (error) {27 logEarlyResult(error, startTime, verboseInfo);28 throw error;19 unmodified lines48 const throwInvalidSyncOption = value => {49 throw new TypeError(`The "${value}" option cannot be used with synchronous methods.`);50 };51 52-const spawnSubprocessSync = ({file, args, options, command, escapedCommand, fileDescriptors, startTime}) => {52+const spawnSubprocessSync = ({file, args, options, command, escapedCommand, verboseInfo, fileDescriptors, startTime}) => {53 const syncResult = runSubprocessSync({file, args, options, command, escapedCommand, fileDescriptors, startTime});54 if (syncResult.failed) {55 return syncResult;56 }57 58 const {resultError, exitCode, signal, timedOut, isMaxBuffer} = getSyncExitResult(syncResult, options);59- const {output, error = resultError} = transformOutputSync({fileDescriptors, syncResult, options, isMaxBuffer});59+ const {output, error = resultError} = transformOutputSync({fileDescriptors, syncResult, options, isMaxBuffer, verboseInfo});60 const stdio = output.map(stdioOutput => stripNewline(stdioOutput, options));61 const all = stripNewline(getAllSync(output, options), options);62 return getSyncResult({error, exitCode, signal, timedOut, stdio, all, options, command, escapedCommand, startTime});63 };29 unmodified lines