1 | import { Observable } from "rxjs";
|
2 | import { SpawnOptions } from "child_process";
|
3 | /**
|
4 | * Finds the actual executable and parameters to run on Windows. This method
|
5 | * mimics the POSIX behavior of being able to run scripts as executables by
|
6 | * replacing the passed-in executable with the script runner, for PowerShell,
|
7 | * CMD, and node scripts.
|
8 | *
|
9 | * This method also does the work of running down PATH, which spawn on Windows
|
10 | * also doesn't do, unlike on POSIX.
|
11 | *
|
12 | * @param {string} exe The executable to run
|
13 | * @param {string[]} args The arguments to run
|
14 | *
|
15 | * @return {Object} The cmd and args to run
|
16 | * @property {string} cmd The command to pass to spawn
|
17 | * @property {string[]} args The arguments to pass to spawn
|
18 | */
|
19 | export declare function findActualExecutable(exe: string, args: string[]): {
|
20 | cmd: string;
|
21 | args: string[];
|
22 | };
|
23 | export type SpawnRxExtras = {
|
24 | stdin?: Observable<string>;
|
25 | echoOutput?: boolean;
|
26 | split?: boolean;
|
27 | jobber?: boolean;
|
28 | encoding?: BufferEncoding;
|
29 | };
|
30 | export type OutputLine = {
|
31 | source: "stdout" | "stderr";
|
32 | text: string;
|
33 | };
|
34 | /**
|
35 | * Spawns a process but detached from the current process. The process is put
|
36 | * into its own Process Group that can be killed by unsubscribing from the
|
37 | * return Observable.
|
38 | *
|
39 | * @param {string} exe The executable to run
|
40 | * @param {string[]} params The parameters to pass to the child
|
41 | * @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
42 | *
|
43 | * @return {Observable<OutputLine>} Returns an Observable that when subscribed
|
44 | * to, will create a detached process. The
|
45 | * process output will be streamed to this
|
46 | * Observable, and if unsubscribed from, the
|
47 | * process will be terminated early. If the
|
48 | * process terminates with a non-zero value,
|
49 | * the Observable will terminate with onError.
|
50 | */
|
51 | export declare function spawnDetached(exe: string, params: string[], opts: SpawnOptions & SpawnRxExtras & {
|
52 | split: true;
|
53 | }): Observable<OutputLine>;
|
54 | /**
|
55 | * Spawns a process but detached from the current process. The process is put
|
56 | * into its own Process Group that can be killed by unsubscribing from the
|
57 | * return Observable.
|
58 | *
|
59 | * @param {string} exe The executable to run
|
60 | * @param {string[]} params The parameters to pass to the child
|
61 | * @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
62 | *
|
63 | * @return {Observable<string>} Returns an Observable that when subscribed
|
64 | * to, will create a detached process. The
|
65 | * process output will be streamed to this
|
66 | * Observable, and if unsubscribed from, the
|
67 | * process will be terminated early. If the
|
68 | * process terminates with a non-zero value,
|
69 | * the Observable will terminate with onError.
|
70 | */
|
71 | export declare function spawnDetached(exe: string, params: string[], opts?: SpawnOptions & SpawnRxExtras & {
|
72 | split: false | undefined;
|
73 | }): Observable<string>;
|
74 | /**
|
75 | * Spawns a process attached as a child of the current process.
|
76 | *
|
77 | * @param {string} exe The executable to run
|
78 | * @param {string[]} params The parameters to pass to the child
|
79 | * @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
80 | *
|
81 | * @return {Observable<OutputLine>} Returns an Observable that when subscribed
|
82 | * to, will create a child process. The
|
83 | * process output will be streamed to this
|
84 | * Observable, and if unsubscribed from, the
|
85 | * process will be terminated early. If the
|
86 | * process terminates with a non-zero value,
|
87 | * the Observable will terminate with onError.
|
88 | */
|
89 | export declare function spawn(exe: string, params: string[], opts: SpawnOptions & SpawnRxExtras & {
|
90 | split: true;
|
91 | }): Observable<OutputLine>;
|
92 | /**
|
93 | * Spawns a process attached as a child of the current process.
|
94 | *
|
95 | * @param {string} exe The executable to run
|
96 | * @param {string[]} params The parameters to pass to the child
|
97 | * @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
98 | *
|
99 | * @return {Observable<string>} Returns an Observable that when subscribed
|
100 | * to, will create a child process. The
|
101 | * process output will be streamed to this
|
102 | * Observable, and if unsubscribed from, the
|
103 | * process will be terminated early. If the
|
104 | * process terminates with a non-zero value,
|
105 | * the Observable will terminate with onError.
|
106 | */
|
107 | export declare function spawn(exe: string, params: string[], opts?: SpawnOptions & SpawnRxExtras & {
|
108 | split: false | undefined;
|
109 | }): Observable<string>;
|
110 | /**
|
111 | * Spawns a process but detached from the current process. The process is put
|
112 | * into its own Process Group.
|
113 | *
|
114 | * @param {string} exe The executable to run
|
115 | * @param {string[]} params The parameters to pass to the child
|
116 | * @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
117 | *
|
118 | * @return {Promise<[string, string]>} Returns an Promise that represents a detached
|
119 | * process. The value returned is the process
|
120 | * output. If the process terminates with a
|
121 | * non-zero value, the Promise will resolve with
|
122 | * an Error.
|
123 | */
|
124 | export declare function spawnDetachedPromise(exe: string, params: string[], opts: SpawnOptions & SpawnRxExtras & {
|
125 | split: true;
|
126 | }): Promise<[string, string]>;
|
127 | /**
|
128 | * Spawns a process but detached from the current process. The process is put
|
129 | * into its own Process Group.
|
130 | *
|
131 | * @param {string} exe The executable to run
|
132 | * @param {string[]} params The parameters to pass to the child
|
133 | * @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
134 | *
|
135 | * @return {Promise<string>} Returns an Promise that represents a detached
|
136 | * process. The value returned is the process
|
137 | * output. If the process terminates with a
|
138 | * non-zero value, the Promise will resolve with
|
139 | * an Error.
|
140 | */
|
141 | export declare function spawnDetachedPromise(exe: string, params: string[], opts?: SpawnOptions & SpawnRxExtras & {
|
142 | split: false | undefined;
|
143 | }): Promise<string>;
|
144 | /**
|
145 | * Spawns a process as a child process.
|
146 | *
|
147 | * @param {string} exe The executable to run
|
148 | * @param {string[]} params The parameters to pass to the child
|
149 | * @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
150 | *
|
151 | * @return {Promise<[string, string]>} Returns an Promise that represents a child
|
152 | * process. The value returned is the process
|
153 | * output. If the process terminates with a
|
154 | * non-zero value, the Promise will resolve with
|
155 | * an Error.
|
156 | */
|
157 | export declare function spawnPromise(exe: string, params: string[], opts: SpawnOptions & SpawnRxExtras & {
|
158 | split: true;
|
159 | }): Promise<[string, string]>;
|
160 | /**
|
161 | * Spawns a process as a child process.
|
162 | *
|
163 | * @param {string} exe The executable to run
|
164 | * @param {string[]} params The parameters to pass to the child
|
165 | * @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
166 | *
|
167 | * @return {Promise<string>} Returns an Promise that represents a child
|
168 | * process. The value returned is the process
|
169 | * output. If the process terminates with a
|
170 | * non-zero value, the Promise will resolve with
|
171 | * an Error.
|
172 | */
|
173 | export declare function spawnPromise(exe: string, params: string[], opts?: SpawnOptions & SpawnRxExtras): Promise<string>;
|