1 | import { ChildProcess } from "child_process";
|
2 | import { Disposable, HandleableErrorEvent } from "../index";
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | export class BufferedProcess {
|
9 | readonly process?: ChildProcess | undefined;
|
10 |
|
11 | constructor(options: ProcessOptions);
|
12 |
|
13 | // Event Subscription
|
14 | /**
|
15 | * Will call your callback when an error will be raised by the process. Usually
|
16 | * this is due to the command not being available or not on the PATH. You can
|
17 | * call handle() on the object passed to your callback to indicate that you
|
18 | * have handled this error.
|
19 | */
|
20 | onWillThrowError(callback: (errorObject: HandleableErrorEvent) => void): Disposable;
|
21 |
|
22 | // Helper Methods
|
23 | /** Terminate the process. */
|
24 | kill(): void;
|
25 |
|
26 | /** Runs the process. */
|
27 | start(): void;
|
28 | }
|
29 |
|
30 | export interface NodeProcessOptions {
|
31 |
|
32 | command: string;
|
33 |
|
34 |
|
35 | args?: readonly string[] | undefined;
|
36 |
|
37 |
|
38 | options?: SpawnProcessOptions | undefined;
|
39 |
|
40 | |
41 |
|
42 |
|
43 |
|
44 | stdout?(data: string): void;
|
45 |
|
46 | |
47 |
|
48 |
|
49 |
|
50 | stderr?(data: string): void;
|
51 |
|
52 |
|
53 | exit?(code: number): void;
|
54 | }
|
55 |
|
56 | export interface ProcessOptions extends NodeProcessOptions {
|
57 | |
58 |
|
59 |
|
60 |
|
61 | autoStart?: boolean | undefined;
|
62 | }
|
63 |
|
64 | export interface SpawnProcessOptions {
|
65 |
|
66 | cwd?: string | undefined;
|
67 |
|
68 |
|
69 | env?: { [key: string]: string } | undefined;
|
70 |
|
71 |
|
72 | stdio?: string | Array<string | number> | undefined;
|
73 |
|
74 |
|
75 | detached?: boolean | undefined;
|
76 |
|
77 |
|
78 | uid?: number | undefined;
|
79 |
|
80 |
|
81 | gid?: number | undefined;
|
82 |
|
83 | |
84 |
|
85 |
|
86 |
|
87 | shell?: boolean | string | undefined;
|
88 | }
|