@umijs/utils 4.0.0-beta.9 → 4.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled/axios/index.d.ts +29 -14
- package/compiled/axios/index.js +1 -1
- package/compiled/chalk/LICENSE +1 -1
- package/compiled/chalk/index.js +1 -1
- package/compiled/chalk/package.json +1 -1
- package/compiled/chalk/source/index.d.ts +318 -0
- package/compiled/chalk/source/vendor/supports-color/index.d.ts +55 -0
- package/compiled/color/color-convert/conversions.d.ts +87 -87
- package/compiled/color/color-convert/index.d.ts +75 -60
- package/compiled/color/color-convert/route.d.ts +271 -271
- package/compiled/color/index.d.ts +118 -121
- package/compiled/color/index.js +1 -1
- package/compiled/color/package.json +1 -4
- package/compiled/debug/LICENSE +10 -9
- package/compiled/debug/index.js +1 -1
- package/compiled/debug/package.json +1 -1
- package/compiled/execa/index.d.ts +467 -445
- package/compiled/execa/index.js +1 -1
- package/compiled/globby/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
- package/compiled/globby/@nodelib/fs.scandir/out/index.d.ts +12 -0
- package/compiled/globby/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
- package/compiled/globby/@nodelib/fs.scandir/out/settings.d.ts +20 -0
- package/compiled/globby/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
- package/compiled/globby/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
- package/compiled/globby/@nodelib/fs.stat/out/index.d.ts +12 -0
- package/compiled/globby/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
- package/compiled/globby/@nodelib/fs.stat/out/settings.d.ts +16 -0
- package/compiled/globby/@nodelib/fs.stat/out/types/index.d.ts +4 -0
- package/compiled/globby/@nodelib/fs.walk/out/index.d.ts +14 -0
- package/compiled/globby/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
- package/compiled/globby/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
- package/compiled/globby/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
- package/compiled/globby/@nodelib/fs.walk/out/settings.d.ts +30 -0
- package/compiled/globby/@nodelib/fs.walk/out/types/index.d.ts +8 -0
- package/compiled/globby/LICENSE +9 -0
- package/compiled/globby/fast-glob/out/index.d.ts +27 -0
- package/compiled/globby/fast-glob/out/managers/tasks.d.ts +22 -0
- package/compiled/globby/fast-glob/out/settings.d.ts +164 -0
- package/compiled/globby/fast-glob/out/types/index.d.ts +31 -0
- package/compiled/globby/index.d.ts +206 -0
- package/compiled/globby/index.js +37 -0
- package/compiled/globby/package.json +1 -0
- package/compiled/pirates/LICENSE +21 -0
- package/compiled/pirates/index.d.ts +82 -0
- package/compiled/pirates/index.js +1 -0
- package/compiled/pirates/package.json +1 -0
- package/compiled/pkg-up/LICENSE +1 -1
- package/compiled/pkg-up/index.d.ts +55 -44
- package/compiled/pkg-up/index.js +1 -1
- package/compiled/pkg-up/package.json +1 -1
- package/compiled/resolve/index.js +1 -1
- package/compiled/strip-ansi/LICENSE +1 -1
- package/compiled/strip-ansi/index.d.ts +2 -4
- package/compiled/strip-ansi/index.js +1 -1
- package/compiled/strip-ansi/package.json +1 -1
- package/compiled/yargs-parser/index.js +1 -1
- package/dist/getCorejsVersion.d.ts +1 -0
- package/dist/getCorejsVersion.js +11 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +6 -5
- package/dist/installDeps.js +20 -4
- package/dist/isStyleFile.d.ts +5 -0
- package/dist/isStyleFile.js +16 -0
- package/dist/logger.d.ts +8 -6
- package/dist/logger.js +8 -1
- package/dist/register.js +21 -22
- package/dist/tryPaths.d.ts +1 -0
- package/dist/tryPaths.js +11 -0
- package/package.json +19 -18
|
@@ -1,564 +1,586 @@
|
|
|
1
|
-
|
|
2
|
-
import {ChildProcess} from 'child_process';
|
|
3
|
-
import {Stream, Readable as ReadableStream} from 'stream';
|
|
1
|
+
import {Buffer} from 'node:buffer';
|
|
2
|
+
import {ChildProcess} from 'node:child_process';
|
|
3
|
+
import {Stream, Readable as ReadableStream} from 'node:stream';
|
|
4
|
+
|
|
5
|
+
export type StdioOption =
|
|
6
|
+
| 'pipe'
|
|
7
|
+
| 'ipc'
|
|
8
|
+
| 'ignore'
|
|
9
|
+
| 'inherit'
|
|
10
|
+
| Stream
|
|
11
|
+
| number
|
|
12
|
+
| undefined;
|
|
13
|
+
|
|
14
|
+
export interface CommonOptions<EncodingType> {
|
|
15
|
+
/**
|
|
16
|
+
Kill the spawned process when the parent process exits unless either:
|
|
17
|
+
- the spawned process is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)
|
|
18
|
+
- the parent process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit
|
|
4
19
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
| 'ipc'
|
|
9
|
-
| 'ignore'
|
|
10
|
-
| 'inherit'
|
|
11
|
-
| Stream
|
|
12
|
-
| number
|
|
13
|
-
| undefined;
|
|
20
|
+
@default true
|
|
21
|
+
*/
|
|
22
|
+
readonly cleanup?: boolean;
|
|
14
23
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Kill the spawned process when the parent process exits unless either:
|
|
18
|
-
- the spawned process is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)
|
|
19
|
-
- the parent process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit
|
|
24
|
+
/**
|
|
25
|
+
Prefer locally installed binaries when looking for a binary to execute.
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
*/
|
|
23
|
-
readonly cleanup?: boolean;
|
|
27
|
+
If you `$ npm install foo`, you can then `execa('foo')`.
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
@default false
|
|
30
|
+
*/
|
|
31
|
+
readonly preferLocal?: boolean;
|
|
27
32
|
|
|
28
|
-
|
|
33
|
+
/**
|
|
34
|
+
Preferred path to find locally installed binaries in (use with `preferLocal`).
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
*/
|
|
32
|
-
readonly preferLocal?: boolean;
|
|
36
|
+
Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above.
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
@default process.cwd()
|
|
39
|
+
*/
|
|
40
|
+
readonly localDir?: string | URL;
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
readonly localDir?: string;
|
|
42
|
+
/**
|
|
43
|
+
Path to the Node.js executable to use in child processes.
|
|
40
44
|
|
|
41
|
-
|
|
42
|
-
Path to the Node.js executable to use in child processes.
|
|
45
|
+
This can be either an absolute path or a path relative to the `cwd` option.
|
|
43
46
|
|
|
44
|
-
|
|
47
|
+
Requires `preferLocal` to be `true`.
|
|
45
48
|
|
|
46
|
-
|
|
49
|
+
For example, this can be used together with [`get-node`](https://github.com/ehmicky/get-node) to run a specific Node.js version in a child process.
|
|
47
50
|
|
|
48
|
-
|
|
51
|
+
@default process.execPath
|
|
52
|
+
*/
|
|
53
|
+
readonly execPath?: string;
|
|
49
54
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
readonly execPath?: string;
|
|
55
|
+
/**
|
|
56
|
+
Buffer the output from the spawned process. When set to `false`, you must read the output of `stdout` and `stderr` (or `all` if the `all` option is `true`). Otherwise the returned promise will not be resolved/rejected.
|
|
53
57
|
|
|
54
|
-
|
|
55
|
-
Buffer the output from the spawned process. When set to `false`, you must read the output of `stdout` and `stderr` (or `all` if the `all` option is `true`). Otherwise the returned promise will not be resolved/rejected.
|
|
58
|
+
If the spawned process fails, `error.stdout`, `error.stderr`, and `error.all` will contain the buffered data.
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
@default true
|
|
61
|
+
*/
|
|
62
|
+
readonly buffer?: boolean;
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
readonly buffer?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
@default 'pipe'
|
|
68
|
+
*/
|
|
69
|
+
readonly stdin?: StdioOption;
|
|
65
70
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
readonly stdin?: StdioOption;
|
|
71
|
+
/**
|
|
72
|
+
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
|
69
73
|
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
@default 'pipe'
|
|
75
|
+
*/
|
|
76
|
+
readonly stdout?: StdioOption;
|
|
72
77
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
readonly stdout?: StdioOption;
|
|
78
|
+
/**
|
|
79
|
+
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
|
76
80
|
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
@default 'pipe'
|
|
82
|
+
*/
|
|
83
|
+
readonly stderr?: StdioOption;
|
|
79
84
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
readonly stderr?: StdioOption;
|
|
85
|
+
/**
|
|
86
|
+
Setting this to `false` resolves the promise with the error instead of rejecting it.
|
|
83
87
|
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
@default true
|
|
89
|
+
*/
|
|
90
|
+
readonly reject?: boolean;
|
|
86
91
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
readonly reject?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
Add an `.all` property on the promise and the resolved value. The property contains the output of the process with `stdout` and `stderr` interleaved.
|
|
90
94
|
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
@default false
|
|
96
|
+
*/
|
|
97
|
+
readonly all?: boolean;
|
|
93
98
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
readonly all?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.
|
|
97
101
|
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
@default true
|
|
103
|
+
*/
|
|
104
|
+
readonly stripFinalNewline?: boolean;
|
|
100
105
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
readonly stripFinalNewline?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
Set to `false` if you don't want to extend the environment variables when providing the `env` property.
|
|
104
108
|
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
@default true
|
|
110
|
+
*/
|
|
111
|
+
readonly extendEnv?: boolean;
|
|
107
112
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
readonly extendEnv?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
Current working directory of the child process.
|
|
111
115
|
|
|
112
|
-
|
|
113
|
-
Current working directory of the child process.
|
|
116
|
+
Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above.
|
|
114
117
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
+
@default process.cwd()
|
|
119
|
+
*/
|
|
120
|
+
readonly cwd?: string | URL;
|
|
118
121
|
|
|
119
|
-
|
|
120
|
-
|
|
122
|
+
/**
|
|
123
|
+
Environment key-value pairs. Extends automatically from `process.env`. Set `extendEnv` to `false` if you don't want this.
|
|
121
124
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
@default process.env
|
|
126
|
+
*/
|
|
127
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` or `file` if not specified.
|
|
131
|
+
*/
|
|
132
|
+
readonly argv0?: string;
|
|
125
133
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*/
|
|
129
|
-
readonly argv0?: string;
|
|
134
|
+
/**
|
|
135
|
+
Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.
|
|
130
136
|
|
|
131
|
-
|
|
132
|
-
|
|
137
|
+
@default 'pipe'
|
|
138
|
+
*/
|
|
139
|
+
readonly stdio?: 'pipe' | 'ignore' | 'inherit' | readonly StdioOption[];
|
|
133
140
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
141
|
+
/**
|
|
142
|
+
Specify the kind of serialization used for sending messages between processes when using the `stdio: 'ipc'` option or `execaNode()`:
|
|
143
|
+
- `json`: Uses `JSON.stringify()` and `JSON.parse()`.
|
|
144
|
+
- `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)
|
|
137
145
|
|
|
138
|
-
|
|
139
|
-
Specify the kind of serialization used for sending messages between processes when using the `stdio: 'ipc'` option or `execa.node()`:
|
|
140
|
-
- `json`: Uses `JSON.stringify()` and `JSON.parse()`.
|
|
141
|
-
- `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)
|
|
146
|
+
Requires Node.js `13.2.0` or later.
|
|
142
147
|
|
|
143
|
-
|
|
148
|
+
[More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)
|
|
144
149
|
|
|
145
|
-
|
|
150
|
+
@default 'json'
|
|
151
|
+
*/
|
|
152
|
+
readonly serialization?: 'json' | 'advanced';
|
|
146
153
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
readonly serialization?: 'json' | 'advanced';
|
|
154
|
+
/**
|
|
155
|
+
Prepare child to run independently of its parent process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached).
|
|
150
156
|
|
|
151
|
-
|
|
152
|
-
|
|
157
|
+
@default false
|
|
158
|
+
*/
|
|
159
|
+
readonly detached?: boolean;
|
|
153
160
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
161
|
+
/**
|
|
162
|
+
Sets the user identity of the process.
|
|
163
|
+
*/
|
|
164
|
+
readonly uid?: number;
|
|
157
165
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
166
|
+
/**
|
|
167
|
+
Sets the group identity of the process.
|
|
168
|
+
*/
|
|
169
|
+
readonly gid?: number;
|
|
162
170
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
*/
|
|
166
|
-
readonly gid?: number;
|
|
171
|
+
/**
|
|
172
|
+
If `true`, runs `command` inside of a shell. Uses `/bin/sh` on UNIX and `cmd.exe` on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.
|
|
167
173
|
|
|
168
|
-
|
|
169
|
-
|
|
174
|
+
We recommend against using this option since it is:
|
|
175
|
+
- not cross-platform, encouraging shell-specific syntax.
|
|
176
|
+
- slower, because of the additional shell interpretation.
|
|
177
|
+
- unsafe, potentially allowing command injection.
|
|
170
178
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
- unsafe, potentially allowing command injection.
|
|
179
|
+
@default false
|
|
180
|
+
*/
|
|
181
|
+
readonly shell?: boolean | string;
|
|
175
182
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
readonly shell?: boolean | string;
|
|
183
|
+
/**
|
|
184
|
+
Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `null`, then `stdout` and `stderr` will be a `Buffer` instead of a string.
|
|
179
185
|
|
|
180
|
-
|
|
181
|
-
|
|
186
|
+
@default 'utf8'
|
|
187
|
+
*/
|
|
188
|
+
readonly encoding?: EncodingType;
|
|
182
189
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
readonly encoding?: EncodingType;
|
|
190
|
+
/**
|
|
191
|
+
If `timeout` is greater than `0`, the parent will send the signal identified by the `killSignal` property (the default is `SIGTERM`) if the child runs longer than `timeout` milliseconds.
|
|
186
192
|
|
|
187
|
-
|
|
188
|
-
|
|
193
|
+
@default 0
|
|
194
|
+
*/
|
|
195
|
+
readonly timeout?: number;
|
|
189
196
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
readonly timeout?: number;
|
|
197
|
+
/**
|
|
198
|
+
Largest amount of data in bytes allowed on `stdout` or `stderr`. Default: 100 MB.
|
|
193
199
|
|
|
194
|
-
|
|
195
|
-
|
|
200
|
+
@default 100_000_000
|
|
201
|
+
*/
|
|
202
|
+
readonly maxBuffer?: number;
|
|
196
203
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
readonly maxBuffer?: number;
|
|
204
|
+
/**
|
|
205
|
+
Signal value to be used when the spawned process will be killed.
|
|
200
206
|
|
|
201
|
-
|
|
202
|
-
|
|
207
|
+
@default 'SIGTERM'
|
|
208
|
+
*/
|
|
209
|
+
readonly killSignal?: string | number;
|
|
203
210
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
readonly killSignal?: string | number;
|
|
211
|
+
/**
|
|
212
|
+
You can abort the spawned process using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
|
|
207
213
|
|
|
208
|
-
|
|
209
|
-
If `true`, no quoting or escaping of arguments is done on Windows. Ignored on other platforms. This is set to `true` automatically when the `shell` option is `true`.
|
|
214
|
+
When `AbortController.abort()` is called, [`.isCanceled`](https://github.com/sindresorhus/execa#iscanceled) becomes `false`.
|
|
210
215
|
|
|
211
|
-
|
|
212
|
-
*/
|
|
213
|
-
readonly windowsVerbatimArguments?: boolean;
|
|
216
|
+
*Requires Node.js 16 or later.*
|
|
214
217
|
|
|
215
|
-
|
|
216
|
-
|
|
218
|
+
@example
|
|
219
|
+
```js
|
|
220
|
+
import {execa} from './execa';
|
|
217
221
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
readonly windowsHide?: boolean;
|
|
221
|
-
}
|
|
222
|
+
const abortController = new AbortController();
|
|
223
|
+
const subprocess = execa('node', [], {signal: abortController.signal});
|
|
222
224
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
*/
|
|
227
|
-
readonly input?: string | Buffer | ReadableStream;
|
|
228
|
-
}
|
|
225
|
+
setTimeout(() => {
|
|
226
|
+
abortController.abort();
|
|
227
|
+
}, 1000);
|
|
229
228
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
229
|
+
try {
|
|
230
|
+
await subprocess;
|
|
231
|
+
} catch (error) {
|
|
232
|
+
console.log(subprocess.killed); // true
|
|
233
|
+
console.log(error.isCanceled); // true
|
|
235
234
|
}
|
|
235
|
+
```
|
|
236
|
+
*/
|
|
237
|
+
readonly signal?: AbortSignal;
|
|
236
238
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
The Node.js executable to use.
|
|
239
|
+
/**
|
|
240
|
+
If `true`, no quoting or escaping of arguments is done on Windows. Ignored on other platforms. This is set to `true` automatically when the `shell` option is `true`.
|
|
240
241
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
@default false
|
|
243
|
+
*/
|
|
244
|
+
readonly windowsVerbatimArguments?: boolean;
|
|
244
245
|
|
|
245
|
-
|
|
246
|
-
|
|
246
|
+
/**
|
|
247
|
+
On Windows, do not create a new console window. Please note this also prevents `CTRL-C` [from working](https://github.com/nodejs/node/issues/29837) on Windows.
|
|
247
248
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
249
|
+
@default true
|
|
250
|
+
*/
|
|
251
|
+
readonly windowsHide?: boolean;
|
|
252
|
+
}
|
|
252
253
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
command: string;
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
Same as `command` but escaped.
|
|
263
|
-
|
|
264
|
-
This is meant to be copy and pasted into a shell, for debugging purposes.
|
|
265
|
-
Since the escaping is fairly basic, this should not be executed directly as a process, including using `execa()` or `execa.command()`.
|
|
266
|
-
*/
|
|
267
|
-
escapedCommand: string;
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
The numeric exit code of the process that was run.
|
|
271
|
-
*/
|
|
272
|
-
exitCode: number;
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
The output of the process on stdout.
|
|
276
|
-
*/
|
|
277
|
-
stdout: StdoutStderrType;
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
The output of the process on stderr.
|
|
281
|
-
*/
|
|
282
|
-
stderr: StdoutStderrType;
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
Whether the process failed to run.
|
|
286
|
-
*/
|
|
287
|
-
failed: boolean;
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
Whether the process timed out.
|
|
291
|
-
*/
|
|
292
|
-
timedOut: boolean;
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
Whether the process was killed.
|
|
296
|
-
*/
|
|
297
|
-
killed: boolean;
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
The name of the signal that was used to terminate the process. For example, `SIGFPE`.
|
|
301
|
-
|
|
302
|
-
If a signal terminated the process, this property is defined and included in the error message. Otherwise it is `undefined`.
|
|
303
|
-
*/
|
|
304
|
-
signal?: string;
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
A human-friendly description of the signal that was used to terminate the process. For example, `Floating point arithmetic error`.
|
|
308
|
-
|
|
309
|
-
If a signal terminated the process, this property is defined and included in the error message. Otherwise it is `undefined`. It is also `undefined` when the signal is very uncommon which should seldomly happen.
|
|
310
|
-
*/
|
|
311
|
-
signalDescription?: string;
|
|
312
|
-
}
|
|
254
|
+
export interface Options<EncodingType = string> extends CommonOptions<EncodingType> {
|
|
255
|
+
/**
|
|
256
|
+
Write some input to the `stdin` of your binary.
|
|
257
|
+
*/
|
|
258
|
+
readonly input?: string | Buffer | ReadableStream;
|
|
259
|
+
}
|
|
313
260
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
261
|
+
export interface SyncOptions<EncodingType = string> extends CommonOptions<EncodingType> {
|
|
262
|
+
/**
|
|
263
|
+
Write some input to the `stdin` of your binary.
|
|
264
|
+
*/
|
|
265
|
+
readonly input?: string | Buffer;
|
|
266
|
+
}
|
|
317
267
|
|
|
268
|
+
export interface NodeOptions<EncodingType = string> extends Options<EncodingType> {
|
|
318
269
|
/**
|
|
319
|
-
|
|
270
|
+
The Node.js executable to use.
|
|
320
271
|
|
|
321
|
-
|
|
322
|
-
- its exit code is not `0`
|
|
323
|
-
- it was killed with a signal
|
|
324
|
-
- timing out
|
|
325
|
-
- being canceled
|
|
326
|
-
- there's not enough memory or there are already too many child processes
|
|
272
|
+
@default process.execPath
|
|
327
273
|
*/
|
|
328
|
-
|
|
329
|
-
extends ExecaSyncReturnValue<StdoutErrorType> {
|
|
330
|
-
/**
|
|
331
|
-
The output of the process with `stdout` and `stderr` interleaved.
|
|
332
|
-
|
|
333
|
-
This is `undefined` if either:
|
|
334
|
-
- the `all` option is `false` (default value)
|
|
335
|
-
- `execa.sync()` was used
|
|
336
|
-
*/
|
|
337
|
-
all?: StdoutErrorType;
|
|
274
|
+
readonly nodePath?: string;
|
|
338
275
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
*/
|
|
342
|
-
isCanceled: boolean;
|
|
343
|
-
}
|
|
276
|
+
/**
|
|
277
|
+
List of [CLI options](https://nodejs.org/api/cli.html#cli_options) passed to the Node.js executable.
|
|
344
278
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
Error message when the child process failed to run. In addition to the underlying error message, it also contains some information related to why the child process errored.
|
|
279
|
+
@default process.execArgv
|
|
280
|
+
*/
|
|
281
|
+
readonly nodeOptions?: string[];
|
|
282
|
+
}
|
|
350
283
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
284
|
+
export interface ExecaReturnBase<StdoutStderrType> {
|
|
285
|
+
/**
|
|
286
|
+
The file and arguments that were run, for logging purposes.
|
|
354
287
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
shortMessage: string;
|
|
288
|
+
This is not escaped and should not be executed directly as a process, including using `execa()` or `execaCommand()`.
|
|
289
|
+
*/
|
|
290
|
+
command: string;
|
|
359
291
|
|
|
360
|
-
|
|
361
|
-
|
|
292
|
+
/**
|
|
293
|
+
Same as `command` but escaped.
|
|
362
294
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
295
|
+
This is meant to be copy and pasted into a shell, for debugging purposes.
|
|
296
|
+
Since the escaping is fairly basic, this should not be executed directly as a process, including using `execa()` or `execaCommand()`.
|
|
297
|
+
*/
|
|
298
|
+
escapedCommand: string;
|
|
367
299
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
This is `undefined` if either:
|
|
374
|
-
- the `all` option is `false` (default value)
|
|
375
|
-
- `execa.sync()` was used
|
|
376
|
-
*/
|
|
377
|
-
all?: StdoutErrorType;
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
Whether the process was canceled.
|
|
381
|
-
*/
|
|
382
|
-
isCanceled: boolean;
|
|
383
|
-
}
|
|
300
|
+
/**
|
|
301
|
+
The numeric exit code of the process that was run.
|
|
302
|
+
*/
|
|
303
|
+
exitCode: number;
|
|
384
304
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
305
|
+
/**
|
|
306
|
+
The output of the process on stdout.
|
|
307
|
+
*/
|
|
308
|
+
stdout: StdoutStderrType;
|
|
388
309
|
|
|
389
|
-
|
|
310
|
+
/**
|
|
311
|
+
The output of the process on stderr.
|
|
312
|
+
*/
|
|
313
|
+
stderr: StdoutStderrType;
|
|
390
314
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
315
|
+
/**
|
|
316
|
+
Whether the process failed to run.
|
|
317
|
+
*/
|
|
318
|
+
failed: boolean;
|
|
395
319
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
This is `undefined` if either:
|
|
401
|
-
- the `all` option is `false` (the default value)
|
|
402
|
-
- both `stdout` and `stderr` options are set to [`'inherit'`, `'ipc'`, `Stream` or `integer`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio)
|
|
403
|
-
*/
|
|
404
|
-
all?: ReadableStream;
|
|
405
|
-
|
|
406
|
-
catch<ResultType = never>(
|
|
407
|
-
onRejected?: (reason: ExecaError<StdoutErrorType>) => ResultType | PromiseLike<ResultType>
|
|
408
|
-
): Promise<ExecaReturnValue<StdoutErrorType> | ResultType>;
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
Same as the original [`child_process#kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal), except if `signal` is `SIGTERM` (the default value) and the child process is not terminated after 5 seconds, force it by sending `SIGKILL`.
|
|
412
|
-
*/
|
|
413
|
-
kill(signal?: string, options?: KillOptions): void;
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
Similar to [`childProcess.kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal). This is preferred when cancelling the child process execution as the error is more descriptive and [`childProcessResult.isCanceled`](#iscanceled) is set to `true`.
|
|
417
|
-
*/
|
|
418
|
-
cancel(): void;
|
|
419
|
-
}
|
|
320
|
+
/**
|
|
321
|
+
Whether the process timed out.
|
|
322
|
+
*/
|
|
323
|
+
timedOut: boolean;
|
|
420
324
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
325
|
+
/**
|
|
326
|
+
Whether the process was killed.
|
|
327
|
+
*/
|
|
328
|
+
killed: boolean;
|
|
425
329
|
|
|
426
|
-
declare const execa: {
|
|
427
330
|
/**
|
|
428
|
-
|
|
331
|
+
The name of the signal that was used to terminate the process. For example, `SIGFPE`.
|
|
429
332
|
|
|
430
|
-
|
|
333
|
+
If a signal terminated the process, this property is defined and included in the error message. Otherwise it is `undefined`.
|
|
334
|
+
*/
|
|
335
|
+
signal?: string;
|
|
431
336
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
@returns A [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess), which is enhanced to also be a `Promise` for a result `Object` with `stdout` and `stderr` properties.
|
|
337
|
+
/**
|
|
338
|
+
A human-friendly description of the signal that was used to terminate the process. For example, `Floating point arithmetic error`.
|
|
435
339
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
340
|
+
If a signal terminated the process, this property is defined and included in the error message. Otherwise it is `undefined`. It is also `undefined` when the signal is very uncommon which should seldomly happen.
|
|
341
|
+
*/
|
|
342
|
+
signalDescription?: string;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export interface ExecaSyncReturnValue<StdoutErrorType = string>
|
|
346
|
+
extends ExecaReturnBase<StdoutErrorType> {
|
|
347
|
+
}
|
|
439
348
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
349
|
+
/**
|
|
350
|
+
Result of a child process execution. On success this is a plain object. On failure this is also an `Error` instance.
|
|
351
|
+
|
|
352
|
+
The child process fails when:
|
|
353
|
+
- its exit code is not `0`
|
|
354
|
+
- it was killed with a signal
|
|
355
|
+
- timing out
|
|
356
|
+
- being canceled
|
|
357
|
+
- there's not enough memory or there are already too many child processes
|
|
358
|
+
*/
|
|
359
|
+
export interface ExecaReturnValue<StdoutErrorType = string>
|
|
360
|
+
extends ExecaSyncReturnValue<StdoutErrorType> {
|
|
361
|
+
/**
|
|
362
|
+
The output of the process with `stdout` and `stderr` interleaved.
|
|
444
363
|
|
|
445
|
-
|
|
364
|
+
This is `undefined` if either:
|
|
365
|
+
- the `all` option is `false` (default value)
|
|
366
|
+
- `execaSync()` was used
|
|
367
|
+
*/
|
|
368
|
+
all?: StdoutErrorType;
|
|
446
369
|
|
|
447
|
-
|
|
370
|
+
/**
|
|
371
|
+
Whether the process was canceled.
|
|
448
372
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
373
|
+
You can cancel the spawned process using the [`signal`](https://github.com/sindresorhus/execa#signal-1) option.
|
|
374
|
+
*/
|
|
375
|
+
isCanceled: boolean;
|
|
376
|
+
}
|
|
452
377
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
}
|
|
459
|
-
})();
|
|
378
|
+
export interface ExecaSyncError<StdoutErrorType = string>
|
|
379
|
+
extends Error,
|
|
380
|
+
ExecaReturnBase<StdoutErrorType> {
|
|
381
|
+
/**
|
|
382
|
+
Error message when the child process failed to run. In addition to the underlying error message, it also contains some information related to why the child process errored.
|
|
460
383
|
|
|
461
|
-
|
|
462
|
-
execa('echo', ['unicorns']).stdout.pipe(process.stdout);
|
|
463
|
-
```
|
|
384
|
+
The child process stderr then stdout are appended to the end, separated with newlines and not interleaved.
|
|
464
385
|
*/
|
|
465
|
-
|
|
466
|
-
file: string,
|
|
467
|
-
arguments?: readonly string[],
|
|
468
|
-
options?: execa.Options
|
|
469
|
-
): execa.ExecaChildProcess;
|
|
470
|
-
(
|
|
471
|
-
file: string,
|
|
472
|
-
arguments?: readonly string[],
|
|
473
|
-
options?: execa.Options<null>
|
|
474
|
-
): execa.ExecaChildProcess<Buffer>;
|
|
475
|
-
(file: string, options?: execa.Options): execa.ExecaChildProcess;
|
|
476
|
-
(file: string, options?: execa.Options<null>): execa.ExecaChildProcess<
|
|
477
|
-
Buffer
|
|
478
|
-
>;
|
|
386
|
+
message: string;
|
|
479
387
|
|
|
480
388
|
/**
|
|
481
|
-
|
|
389
|
+
This is the same as the `message` property except it does not include the child process stdout/stderr.
|
|
390
|
+
*/
|
|
391
|
+
shortMessage: string;
|
|
482
392
|
|
|
483
|
-
|
|
393
|
+
/**
|
|
394
|
+
Original error message. This is the same as the `message` property except it includes neither the child process stdout/stderr nor some additional information added by Execa.
|
|
484
395
|
|
|
485
|
-
|
|
486
|
-
@param arguments - Arguments to pass to `file` on execution.
|
|
487
|
-
@returns A result `Object` with `stdout` and `stderr` properties.
|
|
396
|
+
This is `undefined` unless the child process exited due to an `error` event or a timeout.
|
|
488
397
|
*/
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
arguments?: readonly string[],
|
|
492
|
-
options?: execa.SyncOptions
|
|
493
|
-
): execa.ExecaSyncReturnValue;
|
|
494
|
-
sync(
|
|
495
|
-
file: string,
|
|
496
|
-
arguments?: readonly string[],
|
|
497
|
-
options?: execa.SyncOptions<null>
|
|
498
|
-
): execa.ExecaSyncReturnValue<Buffer>;
|
|
499
|
-
sync(file: string, options?: execa.SyncOptions): execa.ExecaSyncReturnValue;
|
|
500
|
-
sync(
|
|
501
|
-
file: string,
|
|
502
|
-
options?: execa.SyncOptions<null>
|
|
503
|
-
): execa.ExecaSyncReturnValue<Buffer>;
|
|
398
|
+
originalMessage?: string;
|
|
399
|
+
}
|
|
504
400
|
|
|
401
|
+
export interface ExecaError<StdoutErrorType = string>
|
|
402
|
+
extends ExecaSyncError<StdoutErrorType> {
|
|
505
403
|
/**
|
|
506
|
-
|
|
404
|
+
The output of the process with `stdout` and `stderr` interleaved.
|
|
507
405
|
|
|
508
|
-
|
|
406
|
+
This is `undefined` if either:
|
|
407
|
+
- the `all` option is `false` (default value)
|
|
408
|
+
- `execaSync()` was used
|
|
409
|
+
*/
|
|
410
|
+
all?: StdoutErrorType;
|
|
509
411
|
|
|
510
|
-
|
|
412
|
+
/**
|
|
413
|
+
Whether the process was canceled.
|
|
414
|
+
*/
|
|
415
|
+
isCanceled: boolean;
|
|
416
|
+
}
|
|
511
417
|
|
|
512
|
-
|
|
513
|
-
|
|
418
|
+
export interface KillOptions {
|
|
419
|
+
/**
|
|
420
|
+
Milliseconds to wait for the child process to terminate before sending `SIGKILL`.
|
|
514
421
|
|
|
515
|
-
|
|
516
|
-
```
|
|
517
|
-
import execa = require('./execa');
|
|
422
|
+
Can be disabled with `false`.
|
|
518
423
|
|
|
519
|
-
|
|
520
|
-
const {stdout} = await execa.command('echo unicorns');
|
|
521
|
-
console.log(stdout);
|
|
522
|
-
//=> 'unicorns'
|
|
523
|
-
})();
|
|
524
|
-
```
|
|
424
|
+
@default 5000
|
|
525
425
|
*/
|
|
526
|
-
|
|
527
|
-
|
|
426
|
+
forceKillAfterTimeout?: number | false;
|
|
427
|
+
}
|
|
528
428
|
|
|
429
|
+
export interface ExecaChildPromise<StdoutErrorType> {
|
|
529
430
|
/**
|
|
530
|
-
|
|
431
|
+
Stream combining/interleaving [`stdout`](https://nodejs.org/api/child_process.html#child_process_subprocess_stdout) and [`stderr`](https://nodejs.org/api/child_process.html#child_process_subprocess_stderr).
|
|
531
432
|
|
|
532
|
-
|
|
533
|
-
|
|
433
|
+
This is `undefined` if either:
|
|
434
|
+
- the `all` option is `false` (the default value)
|
|
435
|
+
- both `stdout` and `stderr` options are set to [`'inherit'`, `'ipc'`, `Stream` or `integer`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio)
|
|
534
436
|
*/
|
|
535
|
-
|
|
536
|
-
commandSync(command: string, options?: execa.SyncOptions<null>): execa.ExecaSyncReturnValue<Buffer>;
|
|
437
|
+
all?: ReadableStream;
|
|
537
438
|
|
|
538
|
-
|
|
539
|
-
|
|
439
|
+
catch<ResultType = never>(
|
|
440
|
+
onRejected?: (reason: ExecaError<StdoutErrorType>) => ResultType | PromiseLike<ResultType>
|
|
441
|
+
): Promise<ExecaReturnValue<StdoutErrorType> | ResultType>;
|
|
540
442
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
443
|
+
/**
|
|
444
|
+
Same as the original [`child_process#kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal), except if `signal` is `SIGTERM` (the default value) and the child process is not terminated after 5 seconds, force it by sending `SIGKILL`.
|
|
445
|
+
*/
|
|
446
|
+
kill(signal?: string, options?: KillOptions): void;
|
|
545
447
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
@returns A [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess), which is enhanced to also be a `Promise` for a result `Object` with `stdout` and `stderr` properties.
|
|
448
|
+
/**
|
|
449
|
+
Similar to [`childProcess.kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal). This is preferred when cancelling the child process execution as the error is more descriptive and [`childProcessResult.isCanceled`](#iscanceled) is set to `true`.
|
|
549
450
|
*/
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
451
|
+
cancel(): void;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export type ExecaChildProcess<StdoutErrorType = string> = ChildProcess &
|
|
455
|
+
ExecaChildPromise<StdoutErrorType> &
|
|
456
|
+
Promise<ExecaReturnValue<StdoutErrorType>>;
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
Execute a file.
|
|
460
|
+
|
|
461
|
+
Think of this as a mix of `child_process.execFile` and `child_process.spawn`.
|
|
462
|
+
|
|
463
|
+
@param file - The program/script to execute.
|
|
464
|
+
@param arguments - Arguments to pass to `file` on execution.
|
|
465
|
+
@returns A [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess), which is enhanced to also be a `Promise` for a result `Object` with `stdout` and `stderr` properties.
|
|
466
|
+
|
|
467
|
+
@example
|
|
468
|
+
```
|
|
469
|
+
import {execa} from './execa';
|
|
470
|
+
|
|
471
|
+
const {stdout} = await execa('echo', ['unicorns']);
|
|
472
|
+
console.log(stdout);
|
|
473
|
+
//=> 'unicorns'
|
|
474
|
+
|
|
475
|
+
// Cancelling a spawned process
|
|
476
|
+
|
|
477
|
+
const subprocess = execa('node');
|
|
478
|
+
|
|
479
|
+
setTimeout(() => {
|
|
480
|
+
subprocess.cancel()
|
|
481
|
+
}, 1000);
|
|
482
|
+
|
|
483
|
+
try {
|
|
484
|
+
await subprocess;
|
|
485
|
+
} catch (error) {
|
|
486
|
+
console.log(subprocess.killed); // true
|
|
487
|
+
console.log(error.isCanceled); // true
|
|
488
|
+
}
|
|
563
489
|
|
|
564
|
-
|
|
490
|
+
// Pipe the child process stdout to the current stdout
|
|
491
|
+
execa('echo', ['unicorns']).stdout.pipe(process.stdout);
|
|
492
|
+
```
|
|
493
|
+
*/
|
|
494
|
+
export function execa(
|
|
495
|
+
file: string,
|
|
496
|
+
arguments?: readonly string[],
|
|
497
|
+
options?: Options
|
|
498
|
+
): ExecaChildProcess;
|
|
499
|
+
export function execa(
|
|
500
|
+
file: string,
|
|
501
|
+
arguments?: readonly string[],
|
|
502
|
+
options?: Options<null>
|
|
503
|
+
): ExecaChildProcess<Buffer>;
|
|
504
|
+
export function execa(file: string, options?: Options): ExecaChildProcess;
|
|
505
|
+
export function execa(file: string, options?: Options<null>): ExecaChildProcess<Buffer>;
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
Execute a file synchronously.
|
|
509
|
+
|
|
510
|
+
This method throws an `Error` if the command fails.
|
|
511
|
+
|
|
512
|
+
@param file - The program/script to execute.
|
|
513
|
+
@param arguments - Arguments to pass to `file` on execution.
|
|
514
|
+
@returns A result `Object` with `stdout` and `stderr` properties.
|
|
515
|
+
*/
|
|
516
|
+
export function execaSync(
|
|
517
|
+
file: string,
|
|
518
|
+
arguments?: readonly string[],
|
|
519
|
+
options?: SyncOptions
|
|
520
|
+
): ExecaSyncReturnValue;
|
|
521
|
+
export function execaSync(
|
|
522
|
+
file: string,
|
|
523
|
+
arguments?: readonly string[],
|
|
524
|
+
options?: SyncOptions<null>
|
|
525
|
+
): ExecaSyncReturnValue<Buffer>;
|
|
526
|
+
export function execaSync(file: string, options?: SyncOptions): ExecaSyncReturnValue;
|
|
527
|
+
export function execaSync(
|
|
528
|
+
file: string,
|
|
529
|
+
options?: SyncOptions<null>
|
|
530
|
+
): ExecaSyncReturnValue<Buffer>;
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
Same as `execa()` except both file and arguments are specified in a single `command` string. For example, `execa('echo', ['unicorns'])` is the same as `execaCommand('echo unicorns')`.
|
|
534
|
+
|
|
535
|
+
If the file or an argument contains spaces, they must be escaped with backslashes. This matters especially if `command` is not a constant but a variable, for example with `__dirname` or `process.cwd()`. Except for spaces, no escaping/quoting is needed.
|
|
536
|
+
|
|
537
|
+
The `shell` option must be used if the `command` uses shell-specific features (for example, `&&` or `||`), as opposed to being a simple `file` followed by its `arguments`.
|
|
538
|
+
|
|
539
|
+
@param command - The program/script to execute and its arguments.
|
|
540
|
+
@returns A [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess), which is enhanced to also be a `Promise` for a result `Object` with `stdout` and `stderr` properties.
|
|
541
|
+
|
|
542
|
+
@example
|
|
543
|
+
```
|
|
544
|
+
import {execaCommand} from './execa';
|
|
545
|
+
|
|
546
|
+
const {stdout} = await execaCommand('echo unicorns');
|
|
547
|
+
console.log(stdout);
|
|
548
|
+
//=> 'unicorns'
|
|
549
|
+
```
|
|
550
|
+
*/
|
|
551
|
+
export function execaCommand(command: string, options?: Options): ExecaChildProcess;
|
|
552
|
+
export function execaCommand(command: string, options?: Options<null>): ExecaChildProcess<Buffer>;
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
Same as `execaCommand()` but synchronous.
|
|
556
|
+
|
|
557
|
+
@param command - The program/script to execute and its arguments.
|
|
558
|
+
@returns A result `Object` with `stdout` and `stderr` properties.
|
|
559
|
+
*/
|
|
560
|
+
export function execaCommandSync(command: string, options?: SyncOptions): ExecaSyncReturnValue;
|
|
561
|
+
export function execaCommandSync(command: string, options?: SyncOptions<null>): ExecaSyncReturnValue<Buffer>;
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
Execute a Node.js script as a child process.
|
|
565
|
+
|
|
566
|
+
Same as `execa('node', [scriptPath, ...arguments], options)` except (like [`child_process#fork()`](https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options)):
|
|
567
|
+
- the current Node version and options are used. This can be overridden using the `nodePath` and `nodeArguments` options.
|
|
568
|
+
- the `shell` option cannot be used
|
|
569
|
+
- an extra channel [`ipc`](https://nodejs.org/api/child_process.html#child_process_options_stdio) is passed to [`stdio`](#stdio)
|
|
570
|
+
|
|
571
|
+
@param scriptPath - Node.js script to execute.
|
|
572
|
+
@param arguments - Arguments to pass to `scriptPath` on execution.
|
|
573
|
+
@returns A [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess), which is enhanced to also be a `Promise` for a result `Object` with `stdout` and `stderr` properties.
|
|
574
|
+
*/
|
|
575
|
+
export function execaNode(
|
|
576
|
+
scriptPath: string,
|
|
577
|
+
arguments?: readonly string[],
|
|
578
|
+
options?: NodeOptions
|
|
579
|
+
): ExecaChildProcess;
|
|
580
|
+
export function execaNode(
|
|
581
|
+
scriptPath: string,
|
|
582
|
+
arguments?: readonly string[],
|
|
583
|
+
options?: Options<null>
|
|
584
|
+
): ExecaChildProcess<Buffer>;
|
|
585
|
+
export function execaNode(scriptPath: string, options?: Options): ExecaChildProcess;
|
|
586
|
+
export function execaNode(scriptPath: string, options?: Options<null>): ExecaChildProcess<Buffer>;
|