verbose.d.ts
This file
Path
types/verbose.d.ts
100 lines · 2.6 KiB · TypeScript
Last changed by
Fix documentation and types mistakesSindre Sorhusbefore adoption74b854a
History of this fileTake it
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101import type {FdGenericOption} from './arguments/specific.js';import type {Options, SyncOptions} from './arguments/options.js';import type {Result, SyncResult} from './return/result.js';
export type VerboseOption = FdGenericOption< | 'none' | 'short' | 'full' | VerboseFunction>;
type VerboseFunction = (verboseLine: string, verboseObject: MinimalVerboseObject) => string | void;
type GenericVerboseObject = { /** Event type. This can be: - `'command'`: subprocess start - `'output'`: `stdout`/`stderr` output - `'ipc'`: IPC output - `'error'`: subprocess failure - `'duration'`: subprocess success or failure */ type: 'command' | 'output' | 'ipc' | 'error' | 'duration';
/** Depending on `verboseObject.type`, this is: - `'command'`: the `result.escapedCommand` - `'output'`: one line from `result.stdout` or `result.stderr` - `'ipc'`: one IPC message from `result.ipcOutput` - `'error'`: the `error.shortMessage` - `'duration'`: the `result.durationMs`, formatted as `(done in 29ms)` */ message: string;
/** The file and arguments that were run. This is the same as `result.escapedCommand`. */ escapedCommand: string;
/** Serial number identifying the subprocess within the current process. It is incremented from `'0'`.
This is helpful when multiple subprocesses are running at the same time.
This is similar to a [PID](https://en.wikipedia.org/wiki/Process_identifier) except it has no maximum limit, which means it never repeats. Also, it is usually shorter. */ commandId: string;
/** Event date/time. */ timestamp: Date;
/** Whether this subprocess is the destination of another subprocess' `pipe()` method. This is `true` when it was spawned using the template string or array syntax of `pipe()`, `false` otherwise. */ piped: boolean;};
type MinimalVerboseObject = GenericVerboseObject & { // We cannot use the `CommonOptions` type because it would make this type recursive options: object; result?: never;};
/**Subprocess event object, for logging purpose, using the `verbose` option and `execa()`.*/export type VerboseObject = GenericVerboseObject & { /** The options passed to the subprocess. */ options: Options;
/** Subprocess result.
This is `undefined` if `verboseObject.type` is `'command'`, `'output'` or `'ipc'`. */ result?: Result;};
/**Subprocess event object, for logging purpose, using the `verbose` option and `execaSync()`.*/export type SyncVerboseObject = GenericVerboseObject & { /** The options passed to the subprocess. */ options: SyncOptions;
/** Subprocess result.
This is `undefined` if `verboseObject.type` is `'command'`, `'output'` or `'ipc'`. */ result?: SyncResult;};
export {};