1 | import { Errors, Interfaces } from '@oclif/core';
|
2 | type CaptureOptions = {
|
3 | print?: boolean;
|
4 | stripAnsi?: boolean;
|
5 | testNodeEnv?: string;
|
6 | };
|
7 | type CaptureResult<T> = {
|
8 | error?: Error & Partial<Errors.CLIError>;
|
9 | result?: T;
|
10 | stderr: string;
|
11 | stdout: string;
|
12 | };
|
13 | /**
|
14 | * Capture the stderr and stdout output of a function
|
15 | * @param fn async function to run
|
16 | * @param opts options
|
17 | * - print: Whether to print the output to the console
|
18 | * - stripAnsi: Whether to strip ANSI codes from the output
|
19 | * @returns {Promise<CaptureResult<T>>} Captured output
|
20 | * - error: Error object if the function throws an error
|
21 | * - result: Result of the function if it returns a value and succeeds
|
22 | * - stderr: Captured stderr output
|
23 | * - stdout: Captured stdout output
|
24 | */
|
25 | export declare function captureOutput<T>(fn: () => Promise<unknown>, opts?: CaptureOptions): Promise<CaptureResult<T>>;
|
26 | /**
|
27 | * Capture the stderr and stdout output of a command in your CLI
|
28 | * @param args Command arguments, e.g. `['my:command', '--flag']` or `'my:command --flag'`
|
29 | * @param loadOpts options for loading oclif `Config`
|
30 | * @param captureOpts options for capturing the output
|
31 | * - print: Whether to print the output to the console
|
32 | * - stripAnsi: Whether to strip ANSI codes from the output
|
33 | * @returns {Promise<CaptureResult<T>>} Captured output
|
34 | * - error: Error object if the command throws an error
|
35 | * - result: Result of the command if it returns a value and succeeds
|
36 | * - stderr: Captured stderr output
|
37 | * - stdout: Captured stdout output
|
38 | */
|
39 | export declare function runCommand<T>(args: string | string[], loadOpts?: Interfaces.LoadOptions, captureOpts?: CaptureOptions): Promise<CaptureResult<T>>;
|
40 | /**
|
41 | * Capture the stderr and stdout output of a hook in your CLI
|
42 | * @param hook Hook name
|
43 | * @param options options to pass to the hook
|
44 | * @param loadOpts options for loading oclif `Config`
|
45 | * @param captureOpts options for capturing the output
|
46 | * - print: Whether to print the output to the console
|
47 | * - stripAnsi: Whether to strip ANSI codes from the output
|
48 | * @returns {Promise<CaptureResult<T>>} Captured output
|
49 | * - error: Error object if the hook throws an error
|
50 | * - result: Result of the hook if it returns a value and succeeds
|
51 | * - stderr: Captured stderr output
|
52 | * - stdout: Captured stdout output
|
53 | */
|
54 | export declare function runHook<T>(hook: string, options: Record<string, unknown>, loadOpts?: Interfaces.LoadOptions, captureOpts?: CaptureOptions): Promise<CaptureResult<T>>;
|
55 | export {};
|