Skip to content
Myr

Allow setting different `verbose` values for `stdout`/`stderr` (#970)

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

authored by ehmicky · committed by GitHub · parent fe330a9 · Browse files · 16 files+194 added−57 removed
This commit

State

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

Diff stats

16 files+194 added−57 removed

  • tests:+129 added−28 removed
  • other:+65 added−29 removed

16 files+194 added−57 removed

modified:lib/arguments/create.js+2 added-1 removed
modified:lib/arguments/options.js+2 added-2 removed
modified:lib/arguments/specific.js+13 added-7 removed
1import isPlainObject from 'is-plain-obj';2import {STANDARD_STREAMS_ALIASES} from '../utils.js';3import {verboseDefault} from '../verbose/info.js';45export const normalizeFdSpecificOptions = options => {5 const optionBaseArray = Array.from({length: getStdioLength(options)});66 const optionsCopy = {...options};78 for (const optionName of FD_SPECIFIC_OPTIONS) {9 const optionArray = normalizeFdSpecificOption(options[optionName], [...optionBaseArray], optionName);10 optionsCopy[optionName] = addDefaultValue(optionArray, optionName);9 optionsCopy[optionName] = normalizeFdSpecificOption(options, optionName);10 }1112 return optionsCopy;13};1415export const normalizeFdSpecificOption = (options, optionName) => {16 const optionBaseArray = Array.from({length: getStdioLength(options)});17 const optionArray = normalizeFdSpecificValue(options[optionName], optionBaseArray, optionName);18 return addDefaultValue(optionArray, optionName);19};2021const getStdioLength = ({stdio}) => Array.isArray(stdio)22 ? Math.max(stdio.length, STANDARD_STREAMS_ALIASES.length)23 : STANDARD_STREAMS_ALIASES.length;2420const FD_SPECIFIC_OPTIONS = ['maxBuffer'];2122const normalizeFdSpecificOption = (optionValue, optionArray, optionName) => isPlainObject(optionValue)25const normalizeFdSpecificValue = (optionValue, optionArray, optionName) => isPlainObject(optionValue)26 ? normalizeOptionObject(optionValue, optionArray, optionName)27 : optionArray.fill(optionValue);2829const normalizeOptionObject = (optionValue, optionArray, optionName) => {
43 unmodified lines
73 : optionValue);7475const DEFAULT_OPTIONS = {76 maxBuffer: 1000 * 1000 * 100,77 verbose: verboseDefault,78};7980export const FD_SPECIFIC_OPTIONS = ['maxBuffer', 'verbose'];
modified:lib/stdio/option.js+2 added-2 removed
39 unmodified lines
4041 return stdioOption;42};4344const normalizeStdioSync = (stdioArray, buffer, verbose) => buffer || verbose === 'full'44const normalizeStdioSync = (stdioArray, buffer, verbose) => buffer45 ? stdioArray46 : stdioArray.map((stdioOption, fdNumber) => fdNumber !== 0 && isOutputPipeOnly(stdioOption) ? 'ignore' : stdioOption);46 : stdioArray.map((stdioOption, fdNumber) => fdNumber !== 0 && verbose[fdNumber] !== 'full' && isOutputPipeOnly(stdioOption) ? 'ignore' : stdioOption);4748const isOutputPipeOnly = stdioOption => stdioOption === 'pipe'49 || (Array.isArray(stdioOption) && stdioOption.every(item => item === 'pipe'));50
3 unmodified lines
modified:lib/verbose/complete.js+2 added-1 removed
1import prettyMs from 'pretty-ms';2import {gray} from 'yoctocolors';3import {escapeLines} from '../arguments/escape.js';4import {getDurationMs} from '../return/duration.js';5import {isVerbose} from './info.js';6import {verboseLog} from './log.js';7import {logError} from './error.js';89// When `verbose` is `short|full`, print each command's completion, duration and error
12 unmodified lines
22 });23};2425const logResult = ({message, failed, reject, durationMs, verboseInfo: {verbose, verboseId}}) => {25 if (verbose === 'none') {26 if (!isVerbose(verbose)) {27 return;28 }2930 const icon = getIcon(failed, reject);
16 unmodified lines
modified:lib/verbose/info.js+7 added-4 removed
modified:lib/verbose/output.js+1 added-1 removed
7 unmodified lines
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`.12export const shouldLogOutput = ({stdioItems, encoding, verboseInfo: {verbose}, fdNumber}) => verbose === 'full'12export const shouldLogOutput = ({stdioItems, encoding, verboseInfo: {verbose}, fdNumber}) => verbose[fdNumber] === '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)));
42 unmodified lines
modified:lib/verbose/start.js+2 added-1 removed
modified:test/helpers/verbose.js+13 added-2 removed
5 unmodified lines
67const isWindows = platform === 'win32';8export const QUOTE = isWindows ? '"' : '\'';910const runErrorSubprocess = async (execaMethod, t, verbose) => {10const runErrorSubprocess = async (execaMethod, t, verbose, expectExitCode = true) => {11 const subprocess = execaMethod('noop-fail.js', ['1', foobarString], {verbose});12 await t.throwsAsync(subprocess);13 const {stderr} = await subprocess.parent;14 if (verbose !== 'none') {14 if (expectExitCode) {15 t.true(stderr.includes('exit code 2'));16 }1718 return stderr;
42 unmodified lines
61const normalizeTimestamp = stderr => stderr.replaceAll(/^\[\d{2}:\d{2}:\d{2}.\d{3}]/gm, testTimestamp);62const normalizeDuration = stderr => stderr.replaceAll(/\(done in [^)]+\)/g, '(done in 0ms)');6364export const getVerboseOption = (isVerbose, verbose = 'short') => ({verbose: isVerbose ? verbose : 'none'});6566export const fdNoneOption = {stdout: 'none', stderr: 'none'};67export const fdShortOption = {stdout: 'short', stderr: 'none'};68export const fdFullOption = {stdout: 'full', stderr: 'none'};69export const fdStdoutNoneOption = {stdout: 'none', stderr: 'full'};70export const fdStderrNoneOption = {stdout: 'full', stderr: 'none'};71export const fdStderrShortOption = {stdout: 'none', stderr: 'short'};72export const fdStderrFullOption = {stdout: 'none', stderr: 'full'};73export const fd3NoneOption = {stdout: 'full', fd3: 'none'};74export const fd3ShortOption = {stdout: 'none', fd3: 'short'};75export const fd3FullOption = {stdout: 'none', fd3: 'full'};
modified:test/verbose/complete.js+17 added-4 removed
13 unmodified lines
14 getCompletionLine,15 getCompletionLines,16 testTimestamp,17 getVerboseOption,18 fdNoneOption,19 fdShortOption,20 fdFullOption,21} from '../helpers/verbose.js';2223setFixtureDir();24
3 unmodified lines
28};2930test('Prints completion, verbose "short"', testPrintCompletion, 'short', parentExecaAsync);31test('Prints completion, verbose "full"', testPrintCompletion, 'full', parentExecaAsync);32test('Prints completion, verbose "short", fd-specific', testPrintCompletion, fdShortOption, parentExecaAsync);33test('Prints completion, verbose "full", fd-specific', testPrintCompletion, fdFullOption, parentExecaAsync);34test('Prints completion, verbose "short", sync', testPrintCompletion, 'short', parentExecaSync);35test('Prints completion, verbose "full", sync', testPrintCompletion, 'full', parentExecaSync);36test('Prints completion, verbose "short", fd-specific, sync', testPrintCompletion, fdShortOption, parentExecaSync);37test('Prints completion, verbose "full", fd-specific, sync', testPrintCompletion, fdFullOption, parentExecaSync);3832const testNoPrintCompletion = async (t, execaMethod) => {33 const {stderr} = await execaMethod('noop.js', [foobarString], {verbose: 'none'});39const testNoPrintCompletion = async (t, verbose, execaMethod) => {40 const {stderr} = await execaMethod('noop.js', [foobarString], {verbose});41 t.is(stderr, '');42};4337test('Does not print completion, verbose "none"', testNoPrintCompletion, parentExecaAsync);38test('Does not print completion, verbose "none", sync', testNoPrintCompletion, parentExecaSync);44test('Does not print completion, verbose "none"', testNoPrintCompletion, 'none', parentExecaAsync);45test('Does not print completion, verbose default"', testNoPrintCompletion, undefined, parentExecaAsync);46test('Does not print completion, verbose "none", fd-specific', testNoPrintCompletion, fdNoneOption, parentExecaAsync);47test('Does not print completion, verbose default", fd-specific', testNoPrintCompletion, {}, parentExecaAsync);48test('Does not print completion, verbose "none", sync', testNoPrintCompletion, 'none', parentExecaSync);49test('Does not print completion, verbose default", sync', testNoPrintCompletion, undefined, parentExecaSync);50test('Does not print completion, verbose "none", fd-specific, sync', testNoPrintCompletion, fdNoneOption, parentExecaSync);51test('Does not print completion, verbose default", fd-specific, sync', testNoPrintCompletion, {}, parentExecaSync);5253const testPrintCompletionError = async (t, execaMethod) => {54 const stderr = await execaMethod(t, 'short');55 t.is(getCompletionLine(stderr), `${testTimestamp} [0] × (done in 0ms)`);
52 unmodified lines
modified:test/verbose/error.js+17 added-4 removed
12 unmodified lines
13 getErrorLine,14 getErrorLines,15 testTimestamp,16 getVerboseOption,17 fdNoneOption,18 fdShortOption,19 fdFullOption,20} from '../helpers/verbose.js';2122setFixtureDir();23
5 unmodified lines
29};3031test('Prints error, verbose "short"', testPrintError, 'short', runErrorSubprocessAsync);32test('Prints error, verbose "full"', testPrintError, 'full', runErrorSubprocessAsync);33test('Prints error, verbose "short", fd-specific', testPrintError, fdShortOption, runErrorSubprocessAsync);34test('Prints error, verbose "full", fd-specific', testPrintError, fdFullOption, runErrorSubprocessAsync);35test('Prints error, verbose "short", sync', testPrintError, 'short', runErrorSubprocessSync);36test('Prints error, verbose "full", sync', testPrintError, 'full', runErrorSubprocessSync);37test('Prints error, verbose "short", fd-specific, sync', testPrintError, fdShortOption, runErrorSubprocessSync);38test('Prints error, verbose "full", fd-specific, sync', testPrintError, fdFullOption, runErrorSubprocessSync);3933const testNoPrintError = async (t, execaMethod) => {34 const stderr = await execaMethod(t, 'none');40const testNoPrintError = async (t, verbose, execaMethod) => {41 const stderr = await execaMethod(t, verbose, false);42 t.is(getErrorLine(stderr), undefined);43};4438test('Does not print error, verbose "none"', testNoPrintError, runErrorSubprocessAsync);39test('Does not print error, verbose "none", sync', testNoPrintError, runErrorSubprocessSync);45test('Does not print error, verbose "none"', testNoPrintError, 'none', runErrorSubprocessAsync);46test('Does not print error, verbose default', testNoPrintError, undefined, runErrorSubprocessAsync);47test('Does not print error, verbose "none", fd-specific', testNoPrintError, fdNoneOption, runErrorSubprocessAsync);48test('Does not print error, verbose default, fd-specific', testNoPrintError, {}, runErrorSubprocessAsync);49test('Does not print error, verbose "none", sync', testNoPrintError, 'none', runErrorSubprocessSync);50test('Does not print error, verbose default, sync', testNoPrintError, undefined, runErrorSubprocessSync);51test('Does not print error, verbose "none", fd-specific, sync', testNoPrintError, fdNoneOption, runErrorSubprocessSync);52test('Does not print error, verbose default, fd-specific, sync', testNoPrintError, {}, runErrorSubprocessSync);5354const testPrintNoError = async (t, execaMethod) => {55 const {stderr} = await execaMethod('noop.js', [foobarString], {verbose: 'short'});56 t.is(getErrorLine(stderr), undefined);
89 unmodified lines
modified:test/verbose/output.js+63 added-14 removed
15 unmodified lines
16 getOutputLine,17 getOutputLines,18 testTimestamp,19 getVerboseOption,20 fdShortOption,21 fdFullOption,22 fdStdoutNoneOption,23 fdStderrNoneOption,24 fdStderrShortOption,25 fdStderrFullOption,26 fd3NoneOption,27 fd3ShortOption,28 fd3FullOption,29} from '../helpers/verbose.js';3031setFixtureDir();3224const testPrintOutput = async (t, fdNumber, execaMethod) => {25 const {stderr} = await execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], {verbose: 'full'});33const testPrintOutput = async (t, verbose, fdNumber, execaMethod) => {34 const {stderr} = await execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], {verbose});35 t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);36};3729test('Prints stdout, verbose "full"', testPrintOutput, 1, parentExecaAsync);30test('Prints stdout, verbose "full", sync', testPrintOutput, 1, parentExecaSync);31test('Prints stderr, verbose "full"', testPrintOutput, 2, parentExecaAsync);32test('Prints stderr, verbose "full", sync', testPrintOutput, 2, parentExecaSync);38test('Prints stdout, verbose "full"', testPrintOutput, 'full', 1, parentExecaAsync);39test('Prints stderr, verbose "full"', testPrintOutput, 'full', 2, parentExecaAsync);40test('Prints stdout, verbose "full", fd-specific', testPrintOutput, fdFullOption, 1, parentExecaAsync);41test('Prints stderr, verbose "full", fd-specific', testPrintOutput, fdStderrFullOption, 2, parentExecaAsync);42test('Prints stdout, verbose "full", sync', testPrintOutput, 'full', 1, parentExecaSync);43test('Prints stderr, verbose "full", sync', testPrintOutput, 'full', 2, parentExecaSync);44test('Prints stdout, verbose "full", fd-specific, sync', testPrintOutput, fdFullOption, 1, parentExecaSync);45test('Prints stderr, verbose "full", fd-specific, sync', testPrintOutput, fdStderrFullOption, 2, parentExecaSync);4647const testNoPrintOutput = async (t, verbose, fdNumber, execaMethod) => {48 const {stderr} = await execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], {verbose, ...fullStdio});49 t.is(getOutputLine(stderr), undefined);50};5152test('Does not print stdout, verbose default', testNoPrintOutput, undefined, 1, parentExecaAsync);53test('Does not print stdout, verbose "none"', testNoPrintOutput, 'none', 1, parentExecaAsync);54test('Does not print stdout, verbose "short"', testNoPrintOutput, 'short', 1, parentExecaAsync);41test('Does not print stdout, verbose "none", sync', testNoPrintOutput, 'none', 1, parentExecaSync);42test('Does not print stdout, verbose "short", sync', testNoPrintOutput, 'short', 1, parentExecaSync);55test('Does not print stderr, verbose default', testNoPrintOutput, undefined, 2, parentExecaAsync);56test('Does not print stderr, verbose "none"', testNoPrintOutput, 'none', 2, parentExecaAsync);57test('Does not print stderr, verbose "short"', testNoPrintOutput, 'short', 2, parentExecaAsync);45test('Does not print stderr, verbose "none", sync', testNoPrintOutput, 'none', 2, parentExecaSync);46test('Does not print stderr, verbose "short", sync', testNoPrintOutput, 'short', 2, parentExecaSync);58test('Does not print stdio[*], verbose default', testNoPrintOutput, undefined, 3, parentExecaAsync);59test('Does not print stdio[*], verbose "none"', testNoPrintOutput, 'none', 3, parentExecaAsync);60test('Does not print stdio[*], verbose "short"', testNoPrintOutput, 'short', 3, parentExecaAsync);61test('Does not print stdio[*], verbose "full"', testNoPrintOutput, 'full', 3, parentExecaAsync);62test('Does not print stdout, verbose default, fd-specific', testNoPrintOutput, {}, 1, parentExecaAsync);63test('Does not print stdout, verbose "none", fd-specific', testNoPrintOutput, fdStdoutNoneOption, 1, parentExecaAsync);64test('Does not print stdout, verbose "short", fd-specific', testNoPrintOutput, fdShortOption, 1, parentExecaAsync);65test('Does not print stderr, verbose default, fd-specific', testNoPrintOutput, {}, 2, parentExecaAsync);66test('Does not print stderr, verbose "none", fd-specific', testNoPrintOutput, fdStderrNoneOption, 2, parentExecaAsync);67test('Does not print stderr, verbose "short", fd-specific', testNoPrintOutput, fdStderrShortOption, 2, parentExecaAsync);68test('Does not print stdio[*], verbose default, fd-specific', testNoPrintOutput, {}, 3, parentExecaAsync);69test('Does not print stdio[*], verbose "none", fd-specific', testNoPrintOutput, fd3NoneOption, 3, parentExecaAsync);70test('Does not print stdio[*], verbose "short", fd-specific', testNoPrintOutput, fd3ShortOption, 3, parentExecaAsync);71test('Does not print stdio[*], verbose "full", fd-specific', testNoPrintOutput, fd3FullOption, 3, parentExecaAsync);72test('Does not print stdout, verbose default, sync', testNoPrintOutput, undefined, 1, parentExecaSync);73test('Does not print stdout, verbose "none", sync', testNoPrintOutput, 'none', 1, parentExecaSync);74test('Does not print stdout, verbose "short", sync', testNoPrintOutput, 'short', 1, parentExecaSync);75test('Does not print stderr, verbose default, sync', testNoPrintOutput, undefined, 2, parentExecaSync);76test('Does not print stderr, verbose "none", sync', testNoPrintOutput, 'none', 2, parentExecaSync);77test('Does not print stderr, verbose "short", sync', testNoPrintOutput, 'short', 2, parentExecaSync);78test('Does not print stdio[*], verbose default, sync', testNoPrintOutput, undefined, 3, parentExecaSync);79test('Does not print stdio[*], verbose "none", sync', testNoPrintOutput, 'none', 3, parentExecaSync);80test('Does not print stdio[*], verbose "short", sync', testNoPrintOutput, 'short', 3, parentExecaSync);81test('Does not print stdio[*], verbose "full", sync', testNoPrintOutput, 'full', 3, parentExecaSync);82test('Does not print stdout, verbose default, fd-specific, sync', testNoPrintOutput, {}, 1, parentExecaSync);83test('Does not print stdout, verbose "none", fd-specific, sync', testNoPrintOutput, fdStdoutNoneOption, 1, parentExecaSync);84test('Does not print stdout, verbose "short", fd-specific, sync', testNoPrintOutput, fdShortOption, 1, parentExecaSync);85test('Does not print stderr, verbose default, fd-specific, sync', testNoPrintOutput, {}, 2, parentExecaSync);86test('Does not print stderr, verbose "none", fd-specific, sync', testNoPrintOutput, fdStderrNoneOption, 2, parentExecaSync);87test('Does not print stderr, verbose "short", fd-specific, sync', testNoPrintOutput, fdStderrShortOption, 2, parentExecaSync);88test('Does not print stdio[*], verbose default, fd-specific, sync', testNoPrintOutput, {}, 3, parentExecaSync);89test('Does not print stdio[*], verbose "none", fd-specific, sync', testNoPrintOutput, fd3NoneOption, 3, parentExecaSync);90test('Does not print stdio[*], verbose "short", fd-specific, sync', testNoPrintOutput, fd3ShortOption, 3, parentExecaSync);91test('Does not print stdio[*], verbose "full", fd-specific, sync', testNoPrintOutput, fd3FullOption, 3, parentExecaSync);9293const testPrintError = async (t, execaMethod) => {94 const stderr = await execaMethod(t, 'full');95 t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);
215 unmodified lines
311test('Prints stdout, stdout "pipe", sync', testPrintOutputOptions, {stdout: 'pipe'}, parentExecaSync);312test('Prints stdout, stdout null, sync', testPrintOutputOptions, {stdout: null}, parentExecaSync);313test('Prints stdout, stdout ["pipe"], sync', testPrintOutputOptions, {stdout: ['pipe']}, parentExecaSync);314276const testPrintOutputNoBuffer = async (t, execaMethod) => {277 const {stderr} = await execaMethod('noop.js', [foobarString], {verbose: 'full', buffer: false});315const testPrintOutputNoBuffer = async (t, verbose, execaMethod) => {316 const {stderr} = await execaMethod('noop.js', [foobarString], {verbose, buffer: false});317 t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);318};319281test('Prints stdout, buffer: false', testPrintOutputNoBuffer, parentExecaAsync);282test('Prints stdout, buffer: false, sync', testPrintOutputNoBuffer, parentExecaSync);320test('Prints stdout, buffer: false', testPrintOutputNoBuffer, 'full', parentExecaAsync);321test('Prints stdout, buffer: false, fd-specific', testPrintOutputNoBuffer, fdFullOption, parentExecaAsync);322test('Prints stdout, buffer: false, sync', testPrintOutputNoBuffer, 'full', parentExecaSync);323test('Prints stdout, buffer: false, fd-specific, sync', testPrintOutputNoBuffer, fdFullOption, parentExecaSync);324325const testPrintOutputNoBufferFalse = async (t, execaMethod) => {326 const {stderr} = await execaMethod('noop.js', [foobarString], {verbose: fdStderrFullOption, buffer: false});327 t.is(getOutputLine(stderr), undefined);328};329330test('Does not print stdout, buffer: false, different fd', testPrintOutputNoBufferFalse, parentExecaAsync);331test('Does not print stdout, buffer: false, different fd, sync', testPrintOutputNoBufferFalse, parentExecaSync);332333const testPrintOutputNoBufferTransform = async (t, isSync) => {334 const {stderr} = await parentExeca('nested-transform.js', 'noop.js', [foobarString], {verbose: 'full', buffer: false, type: 'generator', isSync});335 t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarUppercase}`);336};
19 unmodified lines
modified:test/verbose/start.js+19 added-4 removed
12 unmodified lines
13 getCommandLine,14 getCommandLines,15 testTimestamp,16 getVerboseOption,17 fdNoneOption,18 fdShortOption,19 fdFullOption,20} from '../helpers/verbose.js';2122setFixtureDir();23
3 unmodified lines
27};2829test('Prints command, verbose "short"', testPrintCommand, 'short', parentExecaAsync);30test('Prints command, verbose "full"', testPrintCommand, 'full', parentExecaAsync);31test('Prints command, verbose "short", fd-specific', testPrintCommand, fdShortOption, parentExecaAsync);32test('Prints command, verbose "full", fd-specific', testPrintCommand, fdFullOption, parentExecaAsync);33test('Prints command, verbose "short", sync', testPrintCommand, 'short', parentExecaSync);34test('Prints command, verbose "full", sync', testPrintCommand, 'full', parentExecaSync);35test('Prints command, verbose "short", fd-specific, sync', testPrintCommand, fdShortOption, parentExecaSync);36test('Prints command, verbose "full", fd-specific, sync', testPrintCommand, fdFullOption, parentExecaSync);37test('Prints command, verbose "short", worker', testPrintCommand, 'short', parentWorker);38test('Prints command, verbose "full", work', testPrintCommand, 'full', parentWorker);39test('Prints command, verbose "short", fd-specific, worker', testPrintCommand, fdShortOption, parentWorker);40test('Prints command, verbose "full", fd-specific, work', testPrintCommand, fdFullOption, parentWorker);4133const testNoPrintCommand = async (t, execaMethod) => {34 const {stderr} = await execaMethod('noop.js', [foobarString], {verbose: 'none'});42const testNoPrintCommand = async (t, verbose, execaMethod) => {43 const {stderr} = await execaMethod('noop.js', [foobarString], {verbose});44 t.is(stderr, '');45};4638test('Does not print command, verbose "none"', testNoPrintCommand, parentExecaAsync);39test('Does not print command, verbose "none", sync', testNoPrintCommand, parentExecaSync);47test('Does not print command, verbose "none"', testNoPrintCommand, 'none', parentExecaAsync);48test('Does not print command, verbose default', testNoPrintCommand, undefined, parentExecaAsync);49test('Does not print command, verbose "none", fd-specific', testNoPrintCommand, fdNoneOption, parentExecaAsync);50test('Does not print command, verbose default, fd-specific', testNoPrintCommand, {}, parentExecaAsync);51test('Does not print command, verbose "none", sync', testNoPrintCommand, 'none', parentExecaSync);52test('Does not print command, verbose default, sync', testNoPrintCommand, undefined, parentExecaSync);53test('Does not print command, verbose "none", fd-specific, sync', testNoPrintCommand, fdNoneOption, parentExecaSync);54test('Does not print command, verbose default, fd-specific, sync', testNoPrintCommand, {}, parentExecaSync);5556const testPrintCommandError = async (t, execaMethod) => {57 const stderr = await execaMethod(t, 'short');58 t.is(getCommandLine(stderr), `${testTimestamp} [0] $ noop-fail.js 1 ${foobarString}`);
64 unmodified lines
modified:index.d.ts+9 added-7 removed
683 unmodified lines
684 - the `encoding` option is binary.685686 This can also be set to `'full'` by setting the `NODE_DEBUG=execa` environment variable in the current process.687688 By default, this applies to both `stdout` and `stderr`, but different values can also be passed.689690 @default 'none'691 */690 readonly verbose?: 'none' | 'short' | 'full';692 readonly verbose?: FdGenericOption<'none' | 'short' | 'full'>;693694 /**695 Kill the subprocess when the current process exits unless either:696 - the subprocess is `detached`.
75 unmodified lines
772773/**774Subprocess options.775774Some options are related to the subprocess output: `maxBuffer`. By default, those options apply to all file descriptors (`stdout`, `stderr`, etc.). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `fd3`, etc.776Some options are related to the subprocess output: `verbose`, `maxBuffer`. By default, those options apply to all file descriptors (`stdout`, `stderr`, etc.). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `fd3`, etc.777778@example779780```779await execa('./run.js', {maxBuffer: 1e6}) // Same value for stdout and stderr780await execa('./run.js', {maxBuffer: {stdout: 1e4, stderr: 1e6}}) // Different values781await execa('./run.js', {verbose: 'full'}) // Same value for stdout and stderr782await execa('./run.js', {verbose: {stdout: 'none', stderr: 'full'}}) // Different values783```784*/785export type Options = CommonOptions<false>;786787/**788Subprocess options, with synchronous methods.789788Some options are related to the subprocess output: `maxBuffer`. By default, those options apply to all file descriptors (`stdout`, `stderr`, etc.). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `fd3`, etc.790Some options are related to the subprocess output: `verbose`, `maxBuffer`. By default, those options apply to all file descriptors (`stdout`, `stderr`, etc.). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `fd3`, etc.791792@example793794```793execaSync('./run.js', {maxBuffer: 1e6}) // Same value for stdout and stderr794execaSync('./run.js', {maxBuffer: {stdout: 1e4, stderr: 1e6}}) // Different values795execaSync('./run.js', {verbose: 'full'}) // Same value for stdout and stderr796execaSync('./run.js', {verbose: {stdout: 'none', stderr: 'full'}}) // Different values797```798*/799export type SyncOptions = CommonOptions<true>;800
1024 unmodified lines
modified:index.test-d.ts+20 added
1552 unmodified lines
1553execaSync('unicorns', {maxBuffer: {fd1: 0}});1554execaSync('unicorns', {maxBuffer: {fd2: 0}});1555execaSync('unicorns', {maxBuffer: {fd3: 0}});1556expectError(execaSync('unicorns', {maxBuffer: {stdout: '0'}}));1557execa('unicorns', {verbose: {}});1558expectError(execa('unicorns', {verbose: []}));1559execa('unicorns', {verbose: {stdout: 'none'}});1560execa('unicorns', {verbose: {stderr: 'none'}});1561execa('unicorns', {verbose: {stdout: 'none', stderr: 'none'} as const});1562execa('unicorns', {verbose: {all: 'none'}});1563execa('unicorns', {verbose: {fd1: 'none'}});1564execa('unicorns', {verbose: {fd2: 'none'}});1565execa('unicorns', {verbose: {fd3: 'none'}});1566expectError(execa('unicorns', {verbose: {stdout: 'other'}}));1567execaSync('unicorns', {verbose: {}});1568expectError(execaSync('unicorns', {verbose: []}));1569execaSync('unicorns', {verbose: {stdout: 'none'}});1570execaSync('unicorns', {verbose: {stderr: 'none'}});1571execaSync('unicorns', {verbose: {stdout: 'none', stderr: 'none'} as const});1572execaSync('unicorns', {verbose: {all: 'none'}});1573execaSync('unicorns', {verbose: {fd1: 'none'}});1574execaSync('unicorns', {verbose: {fd2: 'none'}});1575execaSync('unicorns', {verbose: {fd3: 'none'}});1576expectError(execaSync('unicorns', {verbose: {stdout: 'other'}}));15771578expectError(execa('unicorns', {stdio: []}));1579expectError(execaSync('unicorns', {stdio: []}));1580expectError(execa('unicorns', {stdio: ['pipe']}));
2304 unmodified lines
modified:readme.md+5 added-3 removed
829 unmodified lines
830Type: `object`831832This lists all options for [`execa()`](#execafile-arguments-options) and the [other methods](#methods).833834Some options are related to the subprocess output: [`maxBuffer`](#optionsmaxbuffer). By default, those options apply to all file descriptors (`stdout`, `stderr`, etc.). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `fd3`, etc.834Some options are related to the subprocess output: [`verbose`](#optionsverbose), [`maxBuffer`](#optionsmaxbuffer). By default, those options apply to all file descriptors (`stdout`, `stderr`, etc.). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `fd3`, etc.835836```js837await execa('./run.js', {maxBuffer: 1e6}) // Same value for stdout and stderr838await execa('./run.js', {maxBuffer: {stdout: 1e4, stderr: 1e6}}) // Different values837await execa('./run.js', {verbose: 'full'}) // Same value for stdout and stderr838await execa('./run.js', {verbose: {stdout: 'none', stderr: 'full'}}) // Different values839```840841#### options.reject842
95 unmodified lines
938- the [`encoding`](#optionsencoding) option is binary.939940This can also be set to `'full'` by setting the `NODE_DEBUG=execa` environment variable in the current process.941942By default, this applies to both `stdout` and `stderr`, but different values can also be passed.943944#### options.buffer945946Type: `boolean`\947Default: `true`
392 unmodified lines