UNPKG

@steelbrain/spawn

Version:

Process spawning APIs beautified

68 lines (67 loc) 2.36 kB
/// <reference types="node" /> import { SpawnOptions, ChildProcess } from 'child_process'; interface ExtendedSpawnOptions<OutputType> extends SpawnOptions { handleChildProcess?: (childProcess: ChildProcess) => void; handleStdout?: (chunk: OutputType) => void; handleStderr?: (chunk: OutputType) => void; } interface ProcessPromise<T = any> extends Promise<T> { kill(signal?: NodeJS.Signals | number): boolean; } export declare function spawn(command: string, args: string[], options: { encoding: 'buffer' | null; } & Omit<ExtendedSpawnOptions<Buffer>, 'stdio'>): ProcessPromise<{ stdout: Buffer; stderr: Buffer; exitCode: number; }>; export declare function spawn(command: string, args: string[], options: { encoding: 'buffer' | null; } & ExtendedSpawnOptions<Buffer>): ProcessPromise<{ stdout: Buffer | null; stderr: Buffer | null; exitCode: number; }>; export declare function spawn(command: string, args: string[], options?: { encoding?: BufferEncoding; } & Omit<ExtendedSpawnOptions<string>, 'stdio'>): ProcessPromise<{ stdout: string; stderr: string; exitCode: number; }>; export declare function spawn(command: string, args: string[], options?: { encoding?: BufferEncoding; } & ExtendedSpawnOptions<string>): ProcessPromise<{ stdout: string | null; stderr: string | null; exitCode: number; }>; export declare function spawnFile(filePath: string, args: string[], options: { encoding: 'buffer' | null; } & Omit<ExtendedSpawnOptions<Buffer>, 'stdio'>): ProcessPromise<{ stdout: Buffer; stderr: Buffer; exitCode: number; }>; export declare function spawnFile(filePath: string, args: string[], options: { encoding: 'buffer' | null; } & ExtendedSpawnOptions<Buffer>): ProcessPromise<{ stdout: Buffer | null; stderr: Buffer | null; exitCode: number; }>; export declare function spawnFile(filePath: string, args: string[], options?: { encoding?: BufferEncoding; } & Omit<ExtendedSpawnOptions<string>, 'stdio'>): ProcessPromise<{ stdout: string; stderr: string; exitCode: number; }>; export declare function spawnFile(filePath: string, args: string[], options?: { encoding?: BufferEncoding; } & ExtendedSpawnOptions<string>): ProcessPromise<{ stdout: string | null; stderr: string | null; exitCode: number; }>; export {};