Skip to content
Myr

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

13 files+105 added−104 removed

modified:lib/convert/loop.js+2 added-1 removed
modified:lib/stdio/async.js+1 added-2 removed
51 unmodified lines
52};5354// 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 ended56export const pipeOutputAsync = (subprocess, fileDescriptors, stdioState, controller) => {57 stdioState.subprocess = subprocess;56export const pipeOutputAsync = (subprocess, fileDescriptors, controller) => {57 const inputStreamsGroups = {};5859 for (const [fdNumber, {stdioItems, direction}] of Object.entries(fileDescriptors)) {60 for (const {stream} of stdioItems.filter(({type}) => TRANSFORM_TYPES.has(type))) {
54 unmodified lines
deleted:lib/stdio/forward.js-16 removed
modified:lib/stdio/generator.js+11 added-10 removed
5 unmodified lines
6import {pipeStreams} from './pipeline.js';7import {isAsyncGenerator} from './type.js';8import {getValidateTransformInput, getValidateTransformReturn} from './validate.js';910export const getObjectMode = (stdioItems, optionName, direction, options) => {11 const transforms = getTransforms(stdioItems, optionName, direction, options);12 if (transforms.length === 0) {13 return false;14 }1516 const {value: {readableObjectMode, writableObjectMode}} = transforms.at(-1);17 return direction === 'input' ? writableObjectMode : readableObjectMode;18};1910export const normalizeTransforms = (stdioItems, optionName, direction, options) => [11 ...stdioItems.filter(({type}) => !TRANSFORM_TYPES.has(type)),12 ...getTransforms(stdioItems, optionName, direction, options),13];
98 unmodified lines
112};113114const sortTransforms = (newTransforms, direction) => direction === 'input' ? newTransforms.reverse() : newTransforms;115116export const getObjectMode = (stdioItems, direction) => {117 const lastTransform = stdioItems.findLast(({type}) => TRANSFORM_TYPES.has(type));118 if (lastTransform === undefined) {119 return false;120 }121122 return direction === 'input'123 ? lastTransform.value.writableObjectMode124 : lastTransform.value.readableObjectMode;125};126127/*128Generators can be used to transform/filter standard streams.129130Generators have a simple syntax, yet allows all of the following:
68 unmodified lines
modified:lib/stdio/handle.js+25 added-28 removed
1import {handleStreamsVerbose} from '../verbose/output.js';1import {getStdioItemType, isRegularUrl, isUnknownStdioString, FILE_TYPES} from './type.js';2import {getStreamDirection} from './direction.js';3import {normalizeStdio} from './option.js';4import {handleNativeStream} from './native.js';5import {handleInputOptions} from './input.js';6import {normalizeTransforms, getObjectMode} from './generator.js';8import {forwardStdio, willPipeFileDescriptor} from './forward.js';78// Handle `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, before spawning, in async/sync mode9export 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};1617// 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'`.23const getFileDescriptor = ({stdioOption, fdNumber, addProperties, options, isSync, stdioState, verboseInfo}) => {20const 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};3132const getOptionName = fdNumber => KNOWN_OPTION_NAMES[fdNumber] ?? `stdio[${fdNumber}]`;33const KNOWN_OPTION_NAMES = ['stdin', 'stdout', 'stderr'];
60 unmodified lines
94 throw new TypeError(`The \`${optionName}: { file: '...' }\` option must be used instead of \`${optionName}: '...'\`.`);95 }96};97100const 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));98const validateFileObjectMode = (stdioItems, objectMode) => {99 if (!objectMode) {100 return;101 }102103 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};108106const addInternalStdioItems = ({stdioItems, fdNumber, optionName, options, stdioState, verboseInfo}) => willPipeFileDescriptor(stdioItems)107 ? [108 ...stdioItems,109 ...handleStreamsVerbose({stdioItems, options, stdioState, verboseInfo, fdNumber, optionName}),110 ]111 : stdioItems;112109// 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.112const addStreamProperties = (stdioItem, addProperties, direction, options) => ({113 ...stdioItem,114 ...addProperties[direction][stdioItem.type](stdioItem, options),115});116121const 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*`.120const forwardStdio = stdioItems => {121 if (stdioItems.length > 1) {122 return stdioItems.some(({value}) => value === 'overlapped') ? 'overlapped' : 'pipe';123 }124126 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
1import {writeFileSync} from 'node:fs';2import {shouldLogOutput, logLinesSync} from '../verbose/output.js';3import {joinToString, joinToUint8Array, bufferToUint8Array, isUint8Array, concatUint8Arrays} from './uint-array.js';4import {getGenerators, runGeneratorsSync} from './generator.js';5import {splitLinesSync} from './split.js';6import {FILE_TYPES} from './type.js';78// Apply `stdout`/`stderr` options, after spawning, in sync mode8export const transformOutputSync = ({fileDescriptors, syncResult: {output}, options, isMaxBuffer}) => {9export const transformOutputSync = ({fileDescriptors, syncResult: {output}, options, isMaxBuffer, verboseInfo}) => {10 if (output === null) {11 return {output: Array.from({length: 3})};12 }1314 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};1919const transformOutputResultSync = ({result, fileDescriptors, fdNumber, state, isMaxBuffer}, {buffer, encoding, lines, stripFinalNewline, maxBuffer}) => {20const transformOutputResultSync = ({result, fileDescriptors, fdNumber, state, isMaxBuffer, verboseInfo}, {buffer, encoding, lines, stripFinalNewline, maxBuffer}) => {21 if (result === null) {22 return;23 }24
1 unmodified line
26 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});3435 if (shouldLogOutput({stdioItems, encoding, verboseInfo, fdNumber})) {36 const linesArray = splitLinesSync(serializedResult, false, objectMode);37 logLinesSync(linesArray, verboseInfo);38 }3940 const returnedResult = buffer ? finalResult : undefined;4142 try {43 if (state.error === undefined) {
21 unmodified lines
65};6667const serializeChunks = ({chunks, objectMode, encoding, lines, stripFinalNewline}) => {68 if (objectMode) {59 return {finalResult: chunks};69 return {serializedResult: chunks};70 }7172 if (encoding === 'buffer') {63 const serializedResult = joinToUint8Array(chunks);64 return {serializedResult, finalResult: serializedResult};73 return {serializedResult: joinToUint8Array(chunks)};74 }7576 const serializedResult = joinToString(chunks, encoding);77 if (lines) {69 return {serializedResult, finalResult: splitLinesSync(serializedResult, !stripFinalNewline)};78 return {serializedResult, finalResult: splitLinesSync(serializedResult, !stripFinalNewline, objectMode)};79 }8072 return {serializedResult, finalResult: serializedResult};81 return {serializedResult};82};8384const writeToFiles = (serializedResult, stdioItems) => {85 for (const {type, path} of stdioItems) {
33 unmodified lines
modified:lib/stdio/split.js+6 added-2 removed
1 unmodified line
2export const getSplitLinesGenerator = (binary, preserveNewlines, skipped, state) => binary || skipped3 ? undefined4 : initializeSplitLines(preserveNewlines, state);56export const splitLinesSync = (string, preserveNewlines) => {6export const splitLinesSync = (chunk, preserveNewlines, objectMode) => objectMode7 ? chunk.flatMap(item => splitLinesItemSync(item, preserveNewlines))8 : splitLinesItemSync(chunk, preserveNewlines);910const splitLinesItemSync = (chunk, preserveNewlines) => {11 const {transform, final} = initializeSplitLines(preserveNewlines, {});8 return [...transform(string), ...final()];12 return [...transform(chunk), ...final()];13};1415const initializeSplitLines = (preserveNewlines, state) => {16 state.previousChunks = '';
93 unmodified lines
modified:lib/stream/all.js+3 added-1 removed
modified:lib/stream/resolve.js+5 added-4 removed
13 unmodified lines
14export 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};2525 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);3031 try {
22 unmodified lines
54 }55};5657// Read the contents of `subprocess.std*` and|or wait for its completion57const 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}));58const 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}));6061// Transforms replace `subprocess.std*`, which means they are not exposed to users.62// However, we still want to wait for their completion.63const waitForOriginalStreams = (originalStreams, subprocess, streamInfo) =>
23 unmodified lines
modified:lib/stream/subprocess.js+9 added-3 removed
1import {setImmediate} from 'node:timers/promises';2import getStream, {getStreamAsArrayBuffer, getStreamAsArray, MaxBufferError} from 'get-stream';3import {iterateForResult} from '../convert/loop.js';4import {isArrayBuffer} from '../stdio/uint-array.js';5import {shouldLogOutput, logLines} from '../verbose/output.js';6import {waitForStream, isInputFileDescriptor} from './wait.js';77export const waitForSubprocessStream = async ({stream, fdNumber, encoding, buffer, maxBuffer, lines, allMixed, stripFinalNewline, streamInfo}) => {8export const waitForSubprocessStream = async ({stream, fdNumber, encoding, buffer, maxBuffer, lines, isAll, allMixed, stripFinalNewline, verboseInfo, streamInfo}) => {9 if (!stream) {10 return;11 }1213 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};2020const waitForDefinedStream = async ({stream, onStreamEnd, fdNumber, encoding, buffer, maxBuffer, lines, allMixed, stripFinalNewline, streamInfo}) => {21const waitForDefinedStream = async ({stream, onStreamEnd, fdNumber, encoding, buffer, maxBuffer, lines, isAll, allMixed, stripFinalNewline, verboseInfo, streamInfo, streamInfo: {fileDescriptors}}) => {22 if (isInputFileDescriptor(streamInfo, fdNumber)) {23 return;24 }2526 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 }3031 if (!buffer) {32 await resumeStream(stream);33 return;34 }
49 unmodified lines
modified:lib/verbose/output.js+14 added-17 removed
1import {inspect} from 'node:util';2import {escapeLines} from '../arguments/escape.js';3import {BINARY_ENCODINGS} from '../arguments/encoding.js';4import {PIPED_STDIO_VALUES} from '../stdio/forward.js';4import {TRANSFORM_TYPES} from '../stdio/generator.js';5import {verboseLog} from './log.js';68export 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 : [];157// `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`.21const shouldLogOutput = ({stdioItems, options: {encoding}, verboseInfo: {verbose}, fdNumber}) => verbose === 'full'12export 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 lines
20// We could print `stdio[3+]` but it often is redirected to files and streams, with the same issue.21// So we only print stdout and stderr.22const fdUsesVerbose = fdNumber => fdNumber === 1 || fdNumber === 2;2333const verboseGenerator = function * ({stdioState, fdNumber, verboseInfo}, line) {34 if (!isPiping(stdioState, fdNumber)) {35 logOutput(line, verboseInfo);24const PIPED_STDIO_VALUES = new Set(['pipe', 'overlapped']);2526export const logLines = async (linesIterable, stream, verboseInfo) => {27 for await (const line of linesIterable) {28 if (!isPipingStream(stream)) {29 logLine(line, verboseInfo);30 }31 }32};3338 yield line;34export const logLinesSync = (linesArray, verboseInfo) => {35 for (const line of linesArray) {36 logLine(line, verboseInfo);37 }38};3940// When `subprocess.stdout|stderr.pipe()` is called, `verbose` becomes a noop.41// This prevents the following problems:
1 unmodified line
43// 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.48const isPiping = (stdioState, fdNumber) => stdioState.subprocess !== undefined && isPipingStream(stdioState.subprocess.stdio[fdNumber]);4947const isPipingStream = stream => stream._readableState.pipes.length > 0;4849// When `verbose` is `full`, print stdout|stderr53const logOutput = (line, {verboseId}) => {50const 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 lines
modified:lib/async.js+7 added-7 removed
14 unmodified lines
15import {getSubprocessResult} from './stream/resolve.js';16import {mergePromise} from './promise.js';1718export 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 lines
2930 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 lines
4647 return {...options, timeoutDuration: timeout, signal: cancelSignal};48};4950const spawnSubprocessAsync = ({file, args, options, startTime, verboseInfo, command, escapedCommand, fileDescriptors, stdioState}) => {50const 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 lines
58 const controller = new AbortController();59 setMaxListeners(Number.POSITIVE_INFINITY, controller.signal);6061 const originalStreams = [...subprocess.stdio];62 pipeOutputAsync(subprocess, fileDescriptors, stdioState, controller);62 pipeOutputAsync(subprocess, fileDescriptors, controller);63 cleanupOnExit(subprocess, options, controller);6465 subprocess.kill = subprocessKill.bind(undefined, {kill: subprocess.kill.bind(subprocess), subprocess, options, controller});66 subprocess.all = makeAllStream(subprocess, options);
10 unmodified lines
77 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();8384 const stdio = stdioResults.map(stdioResult => stripNewline(stdioResult, options));85 const all = stripNewline(allResult, options);
20 unmodified lines
modified:lib/sync.js+4 added-4 removed
8 unmodified lines
9import {getSyncExitResult} from './exit/code.js';1011export 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};1617const handleSyncArguments = (rawFile, rawArgs, rawOptions) => {
2 unmodified lines
20 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 lines
48const throwInvalidSyncOption = value => {49 throw new TypeError(`The "${value}" option cannot be used with synchronous methods.`);50};5152const spawnSubprocessSync = ({file, args, options, command, escapedCommand, fileDescriptors, startTime}) => {52const 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 }5758 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