import { ProcessOutput } from 'zx'; import type { ProcessPromise } from 'zx'; /** * Logs ProcessOutput error and then throws it. Useful * when you want to only log stderr when a program is * unsuccessful. * * @example await $`git push`.quiet().catch(logAndThrow) */ export declare function logAndThrow(e: ProcessOutput): never; /** * Causes SIGINT to be a no-op so that the child process can handle it. * Use with care! */ export declare function ignoreSIGINT(): void; export type PrefixOptions = { /** * Prefix to add to all lines of output */ prefix: string; /** * Wait for all chunks before writing output */ groupOutput?: false; groupPrefix?: never; groupSuffix?: never; includeDuration?: never; } | { /** * Prefix to add to all lines of output */ prefix: string; /** * Wait for all chunks before writing output. * * @default false */ groupOutput: true; /** * Output prefix before group. Automatically adds newlines to start and end. */ groupPrefix?: string; /** * Output suffix after group. Automatically adds newlines to start and end. */ groupSuffix?: string; /** * Measure how long the group takes to execute and add it as a prefix to groupSuffix */ includeDuration?: boolean; }; /** * Adds prefix to all stdout and stderr from process. Requires using `stdio: pipe` and .quiet() * * @example * ```ts * const proc = $`ls -lh` * await prefixOutput('OUTPUT:', proc) * ``` */ export declare function prefixOutput(prefixOrOpts: string | PrefixOptions, proc: ProcessPromise): Promise; /** * Adds prefix to all stdout from process. Requires using `stdio: pipe` * * @example * ```ts * const proc = $`ls -lh` * await prefixStdout('OUTPUT:', proc) * ``` */ export declare function prefixStdout(prefixOrOpts: string | PrefixOptions, proc: ProcessPromise): Promise; /** * Adds prefix to all stderr from process. Requires using `stdio: pipe` and .quiet() * * @example * ```ts * const proc = $`ls -lh` * await prefixStderr('OUTPUT:', proc) * ``` */ export declare function prefixStderr(prefixOrOpts: string | PrefixOptions, proc: ProcessPromise): Promise; export interface CatchProcessErrorOptions { /** * Exit with the same exit code as the `ProcessOutput` error * (128 + the signal number for a signal kill) instead of `1` * * @default false */ useProcessExitCode?: boolean; } /** * Catch zx ProcessOutput errors and exit to prevent showing the stack trace. * * Useful when using zx + commander * * @example Run command and catch process errors * ```ts * import { program } from '@commander-js/extra-typings' * * program * .name('mycli') * * // Don't hang for unresolved promises * .hook('postAction', () => process.exit(0)) * .parseAsync() * .catch((e) => { * // Don't show giant stacktrace for process errors * if (e instanceof ProcessOutput) { * process.exit(1) * } else { * throw e * } * }) * ``` */ export declare function catchProcessError({ useProcessExitCode }?: CatchProcessErrorOptions): (err: unknown) => never; //# sourceMappingURL=proc.d.ts.map