@cloud-cli/exec
Version:
Promise wrapper for child_process.spawn
33 lines (32 loc) • 1.09 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import { EventEmitter } from 'events';
import { spawn, exec as sh } from 'child_process';
export interface ExecOutput {
ok: boolean;
code: number;
stdout: string;
stderr: string;
error?: Error;
}
export type ExecOptions = Parameters<typeof spawn>[2];
export type ShOptions = Parameters<typeof sh>[2];
export declare class Process extends EventEmitter {
protected childProcess: ReturnType<typeof spawn>;
code: number;
completed: boolean;
error: Error;
get hasError(): boolean;
constructor(childProcess: ReturnType<typeof spawn>);
set stdout(value: Buffer);
set stderr(value: Buffer);
private _outputBuffer;
private _errorBuffer;
private stdoutDecoder;
private stderrDecoder;
complete(): void;
get output(): ExecOutput;
}
export declare function execString(command: string, options?: ShOptions): Promise<ExecOutput>;
export declare function exec(command: string, args?: string[], options?: ExecOptions): Promise<ExecOutput>;