UNPKG

@aws-cdk-testing/cli-integ

Version:

Integration tests for the AWS CDK CLI

46 lines (45 loc) 1.5 kB
import * as child from 'child_process'; import * as pty from 'node-pty'; /** * IProcess provides an interface to work with a subprocess. */ export interface IProcess { /** * Register a callback to be invoked when a chunk is written to stdout. */ onStdout(callback: (chunk: Buffer) => void): void; /** * Register a callback to be invoked when a chunk is written to stderr. */ onStderr(callback: (chunk: Buffer) => void): void; /** * Register a callback to be invoked when the process exists. */ onExit(callback: (exitCode: number) => void): void; /** * Register a callback to be invoked if the process failed to start. */ onError(callback: (error: Error) => void): void; /** * Write the process stdin stream. */ writeStdin(data: string): void; /** * Singal that no more data will be written to stdin. In non tty process you must * call this method to make sure the process exits. * * @param delay - optional delay in milliseconds before the signal is sent. * */ endStdin(delay?: number): void; } export declare class Process { /** * Spawn a process with a TTY attached. */ static spawnTTY(command: string, args: string[], options?: pty.IPtyForkOptions | pty.IWindowsPtyForkOptions): IProcess; /** * Spawn a process without a forcing a TTY. */ static spawn(command: string, args: string[], options?: child.SpawnOptions): IProcess; }