Skip to content
Myr

Add `verbose` option (#532)

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

authored by ehmicky · committed by GitHub · parent 58ea251 · Browse files · 8 files+104 added−0 removed
This commit

State

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

Diff stats

8 files+104 added−0 removed

  • tests:+48 added−0 removed
  • other:+56 added−0 removed

8 files+104 added−0 removed

added:lib/verbose.js+19 added
added:test/fixtures/nested.js+7 added
added:test/fixtures/verbose-script.js+6 added
added:test/verbose.js+35 added
modified:index.d.ts+9 added
242 unmodified lines
243244 @default true245 */246 readonly windowsHide?: boolean;247248 /**249 Print each command on `stderr` before executing it.250251 This can also be enabled by setting the `NODE_DEBUG=execa` environment variable in the current process.252253 @default false254 */255 readonly verbose?: boolean;256};257258export type Options<EncodingType = string> = {259 /**
497 unmodified lines
modified:index.js+4 added
10 unmodified lines
11import {spawnedKill, spawnedCancel, setupTimeout, validateTimeout, setExitHandler} from './lib/kill.js';12import {handleInput, getSpawnedResult, makeAllStream, validateInputSync} from './lib/stream.js';13import {mergePromise, getSpawnedPromise} from './lib/promise.js';14import {joinCommand, parseCommand, parseTemplates, getEscapedCommand} from './lib/command.js';15import {logCommand, verboseDefault} from './lib/verbose.js';1617const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;1819const getEnv = ({env: envOption, extendEnv, preferLocal, localDir, execPath}) => {
24 unmodified lines
44 reject: true,45 cleanup: true,46 all: false,47 windowsHide: true,48 verbose: verboseDefault,49 ...options,50 };5152 options.env = getEnv(options);
24 unmodified lines
77export function execa(file, args, options) {78 const parsed = handleArguments(file, args, options);79 const command = joinCommand(file, args);80 const escapedCommand = getEscapedCommand(file, args);81 logCommand(escapedCommand, parsed.options);8283 validateTimeout(parsed.options);8485 let spawned;
81 unmodified lines
167export function execaSync(file, args, options) {168 const parsed = handleArguments(file, args, options);169 const command = joinCommand(file, args);170 const escapedCommand = getEscapedCommand(file, args);171 logCommand(escapedCommand, parsed.options);172173 validateInputSync(parsed.options);174175 let result;
116 unmodified lines
modified:index.test-d.ts+1 added
148 unmodified lines
149execa('unicorns', {killSignal: 9});150execa('unicorns', {signal: new AbortController().signal});151execa('unicorns', {windowsVerbatimArguments: true});152execa('unicorns', {windowsHide: false});153execa('unicorns', {verbose: false});154/* eslint-enable @typescript-eslint/no-floating-promises */155execa('unicorns').kill();156execa('unicorns').kill('SIGKILL');157execa('unicorns').kill(undefined);
121 unmodified lines
modified:readme.md+23 added
99 unmodified lines
100$({stdio: 'inherit'}).sync`echo ${unicorns} rainbows`;101//=> 'unicorns rainbows'102```103104#### Verbose mode105106```sh107> node file.js108unicorns109rainbows110111> NODE_DEBUG=execa node file.js112[16:50:03.305] echo unicorns113unicorns114[16:50:03.308] echo rainbows115rainbows116```117118### Pipe the child process stdout to the parent119120```js121import {execa} from 'execa';
543 unmodified lines
665Default: `true`666667On Windows, do not create a new console window. Please note this also prevents `CTRL-C` [from working](https://github.com/nodejs/node/issues/29837) on Windows.668669#### verbose670671Type: `boolean`\672Default: `false`673674[Print each command](#verbose-mode) on `stderr` before executing it.675676This can also be enabled by setting the `NODE_DEBUG=execa` environment variable in the current process.677678#### nodePath *(For `.node()` only)*679680Type: `string`\681Default: [`process.execPath`](https://nodejs.org/api/process.html#process_process_execpath)
92 unmodified lines