@beenotung/tslib
Version:
utils library in Typescript
38 lines (37 loc) • 1.15 kB
TypeScript
import { exec as _exec, SpawnOptionsWithoutStdio } from 'child_process';
export declare const exec: typeof _exec.__promisify__;
export declare class SpawnError extends Error {
stdout: string;
stderr: string;
processError?: any;
code?: number;
constructor(stdout: string, stderr: string);
}
/**
* Won't throw error, the error handling should be done in callback and if-throw style.
* Use spawnAndWait if you want error handling in try-catch style.
*/
export declare function spawn(options: {
cmd: string;
args?: string[];
options?: SpawnOptionsWithoutStdio;
on_stdout?: (chunk: any) => void;
on_stderr?: (chunk: any) => void;
on_error?: (error: any) => void;
}): Promise<number | null>;
/**
* spawn a child process and return the stdout and stderr in promise
*
* the console is not used to output the stdout and stderr
*
* the error stack is preserved (avoided lost in native event loop)
*/
export declare function spawnAndWait(options: {
cmd: string;
args: string[];
options?: SpawnOptionsWithoutStdio;
}): Promise<{
code: number | null;
stdout: string;
stderr: string;
}>;