storybook 10.2.0-alpha.1 → 10.2.0-alpha.11
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/dist/_browser-chunks/{Color-TNPFN3FC.js → Color-XESOIGZP.js} +9 -568
- package/dist/_browser-chunks/{WithTooltip-IO6J4KBT.js → WithTooltip-65CFNBJE.js} +70 -70
- package/dist/_browser-chunks/{chunk-45UGUKRX.js → chunk-242VQQM5.js} +1 -1
- package/dist/_browser-chunks/{chunk-JP7NCOJX.js → chunk-3LY4VQVK.js} +1 -1
- package/dist/_browser-chunks/{chunk-VYJQ7RU5.js → chunk-G4M6MXF4.js} +31 -27
- package/dist/_browser-chunks/{chunk-BRX2HXH7.js → chunk-IH6QJILI.js} +1 -1
- package/dist/_browser-chunks/{chunk-AS2HQEYC.js → chunk-IWQGIXJS.js} +1 -1
- package/dist/_browser-chunks/{chunk-3IAH5M2U.js → chunk-IYCKG66Y.js} +5 -5
- package/dist/_browser-chunks/{chunk-UD6FQLAF.js → chunk-JK6U3MQW.js} +3 -3
- package/dist/_browser-chunks/{chunk-FQ7SLVLR.js → chunk-JVRDBUUP.js} +20 -1
- package/dist/_browser-chunks/{chunk-GFLS4VP3.js → chunk-LCHBOIHN.js} +6 -6
- package/dist/_browser-chunks/{chunk-CHUV5WSW.js → chunk-LE2LTDW3.js} +1 -1
- package/dist/_browser-chunks/{chunk-IPA5A322.js → chunk-MEXTPDJG.js} +1 -1
- package/dist/_browser-chunks/{chunk-XJNX76GA.js → chunk-NQJGOFZV.js} +4 -4
- package/dist/_browser-chunks/chunk-NZMVUW5T.js +7 -0
- package/dist/_browser-chunks/{chunk-2XZMBGTA.js → chunk-POMIZRJL.js} +3 -3
- package/dist/_browser-chunks/{chunk-RP5RXKFU.js → chunk-Q5RYDXT3.js} +38 -30
- package/dist/_browser-chunks/{chunk-SS2NHR7W.js → chunk-RBABWY22.js} +18 -18
- package/dist/_browser-chunks/{chunk-AXG2BOBL.js → chunk-S6TK43XQ.js} +10 -10
- package/dist/_browser-chunks/{chunk-AIOS4NGK.js → chunk-SWJP5COI.js} +11 -11
- package/dist/_browser-chunks/{chunk-H6XK3RSC.js → chunk-UAYGIC3L.js} +6 -6
- package/dist/_browser-chunks/{chunk-YKE5S47A.js → chunk-V2VKKSMQ.js} +18 -18
- package/dist/_browser-chunks/{chunk-GFY5R5EY.js → chunk-V5NV5R37.js} +1 -1
- package/dist/_browser-chunks/chunk-VIJ7SQRO.js +568 -0
- package/dist/_browser-chunks/{chunk-3OXGAGBE.js → chunk-XLJZ7AOP.js} +14 -14
- package/dist/_browser-chunks/{chunk-P4F4UVXX.js → chunk-YKABRMAI.js} +15 -15
- package/dist/_browser-chunks/{chunk-WJYERY3R.js → chunk-ZCFV7BZB.js} +2 -2
- package/dist/_browser-chunks/{formatter-QJ4M4OGQ.js → formatter-EIJCOSYU.js} +2 -2
- package/dist/_browser-chunks/{syntaxhighlighter-IQDEPFLK.js → syntaxhighlighter-ED5Y7EFY.js} +119 -119
- package/dist/_node-chunks/{builder-manager-LXL5N6M5.js → builder-manager-MNAUTRWW.js} +23 -22
- package/dist/_node-chunks/camelcase-6H4Z5R35.js +62 -0
- package/dist/_node-chunks/chunk-2CGMTALY.js +61 -0
- package/dist/_node-chunks/{chunk-ZI2RAI3I.js → chunk-2DZGIXSN.js} +26 -7
- package/dist/_node-chunks/{chunk-4BQMSZKI.js → chunk-5L22ATN3.js} +165 -191
- package/dist/_node-chunks/{chunk-77APSTTM.js → chunk-7FH4U6XC.js} +8 -9
- package/dist/_node-chunks/chunk-CMQYFTBQ.js +126 -0
- package/dist/_node-chunks/{chunk-GOOBGRAV.js → chunk-F3OHO2BC.js} +34 -24
- package/dist/_node-chunks/{chunk-5NWCBUGD.js → chunk-FWVZUHZX.js} +6 -6
- package/dist/_node-chunks/{chunk-KXDU466E.js → chunk-GRH5JFTX.js} +31 -31
- package/dist/_node-chunks/{chunk-CLNMK7MP.js → chunk-HXFHXVEW.js} +5434 -1625
- package/dist/_node-chunks/{chunk-VFTNRF5X.js → chunk-KAIK7772.js} +17 -17
- package/dist/_node-chunks/{chunk-FTR6MHOX.js → chunk-KU4SWNDM.js} +59 -147
- package/dist/_node-chunks/chunk-KX7OAVXY.js +18 -0
- package/dist/_node-chunks/{chunk-TP6ICLTL.js → chunk-L22DGLKT.js} +6 -6
- package/dist/_node-chunks/{chunk-5GNBLJKS.js → chunk-MAMDH2R3.js} +8 -8
- package/dist/_node-chunks/{chunk-PGFQADZC.js → chunk-MAQAZSXK.js} +7 -7
- package/dist/_node-chunks/{chunk-JYMZJCZ7.js → chunk-O7O53MP7.js} +62 -124
- package/dist/_node-chunks/chunk-P663SP7U.js +20 -0
- package/dist/_node-chunks/chunk-RI4IBKXZ.js +23 -0
- package/dist/_node-chunks/{chunk-SR5ZYD7K.js → chunk-RJY225Z5.js} +8 -8
- package/dist/_node-chunks/{chunk-KMTK5W6O.js → chunk-TFY6QV57.js} +48 -26
- package/dist/_node-chunks/{chunk-ET4VMMZG.js → chunk-TOMGRF4A.js} +77 -16
- package/dist/_node-chunks/{chunk-R3WYNAT5.js → chunk-UNUWAUGG.js} +6 -6
- package/dist/_node-chunks/{chunk-LEDV47V2.js → chunk-UOHDPKIW.js} +15 -15
- package/dist/_node-chunks/{chunk-AJUO2ZU3.js → chunk-URWJMVZI.js} +9 -9
- package/dist/_node-chunks/{chunk-TX77W2KY.js → chunk-UYMZAYR4.js} +597 -593
- package/dist/_node-chunks/{chunk-F7377GT2.js → chunk-WHIAK7AH.js} +111 -38
- package/dist/_node-chunks/{chunk-GYZQMMTN.js → chunk-WQ4WQYSZ.js} +9 -9
- package/dist/_node-chunks/{dist-HGQ5R6JU.js → dist-ZOBQQCBA.js} +10 -10
- package/dist/_node-chunks/{globby-5XJTXKUJ.js → globby-WNZSV3ZO.js} +155 -164
- package/dist/_node-chunks/{lib-XNLTS2RI.js → lib-YUWKNDR2.js} +16 -16
- package/dist/_node-chunks/{mdx-N42X6CFJ-7WF3QWVO.js → mdx-N42X6CFJ-K5BCUPEA.js} +11 -11
- package/dist/_node-chunks/{p-limit-RBKYTJKF.js → p-limit-ROJSQI7F.js} +19 -15
- package/dist/babel/index.js +10 -10
- package/dist/bin/core.js +40 -34
- package/dist/bin/dispatcher.js +11 -11
- package/dist/bin/loader.js +14 -11
- package/dist/channels/index.js +3 -3
- package/dist/cli/index.d.ts +1330 -250
- package/dist/cli/index.js +18 -18
- package/dist/common/index.d.ts +1344 -289
- package/dist/common/index.js +22 -22
- package/dist/components/index.d.ts +9 -2
- package/dist/components/index.js +339 -317
- package/dist/core-events/index.d.ts +4 -2
- package/dist/core-events/index.js +4 -2
- package/dist/core-server/index.d.ts +71 -2
- package/dist/core-server/index.js +3381 -3529
- package/dist/core-server/presets/common-manager.css +2 -2
- package/dist/core-server/presets/common-manager.js +93 -65
- package/dist/core-server/presets/common-override-preset.js +9 -9
- package/dist/core-server/presets/common-preset.js +86 -118
- package/dist/csf/index.d.ts +41 -11
- package/dist/csf/index.js +46 -39
- package/dist/csf-tools/index.js +9 -9
- package/dist/docs-tools/index.js +5 -5
- package/dist/instrumenter/index.js +1 -1
- package/dist/manager/globals-runtime.js +9402 -7204
- package/dist/manager/runtime.js +195 -153
- package/dist/manager-api/index.js +34 -26
- package/dist/manager-errors.d.ts +24 -0
- package/dist/manager-errors.js +2 -2
- package/dist/mocking-utils/index.js +14 -14
- package/dist/node-logger/index.d.ts +1456 -111
- package/dist/node-logger/index.js +9 -9
- package/dist/preview/runtime.js +4608 -2436
- package/dist/preview-api/index.d.ts +67 -68
- package/dist/preview-api/index.js +12 -12
- package/dist/preview-errors.d.ts +24 -0
- package/dist/preview-errors.js +3 -3
- package/dist/router/index.js +11 -11
- package/dist/server-errors.d.ts +59 -3
- package/dist/server-errors.js +22 -11
- package/dist/telemetry/index.d.ts +10 -3
- package/dist/telemetry/index.js +27 -25
- package/dist/test/index.js +3237 -1653
- package/dist/theming/create.js +3 -3
- package/dist/theming/index.d.ts +5 -5
- package/dist/theming/index.js +38 -38
- package/dist/types/index.d.ts +12 -6
- package/dist/viewport/index.d.ts +3 -3
- package/package.json +27 -33
- package/dist/_browser-chunks/chunk-EZSQOHRI.js +0 -18
- package/dist/_browser-chunks/chunk-QKODTO7K.js +0 -7
- package/dist/_node-chunks/camelcase-64II7H4U.js +0 -37
- package/dist/_node-chunks/chunk-4EZYJUAC.js +0 -70
- package/dist/_node-chunks/chunk-COQ27OZ3.js +0 -61
- package/dist/_node-chunks/chunk-MC2R4DSD.js +0 -20
- package/dist/_node-chunks/chunk-NEENMS4J.js +0 -18
- package/dist/_node-chunks/chunk-VR5LMO3F.js +0 -72
- package/dist/_node-chunks/chunk-XEPVDCRL.js +0 -23
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Readable, Writable } from 'node:stream';
|
|
2
|
+
import { Readable, Writable, Duplex } from 'node:stream';
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
|
-
import { Buffer } from 'node:buffer';
|
|
5
4
|
import { ChildProcess } from 'node:child_process';
|
|
5
|
+
import { SignalConstants } from 'node:os';
|
|
6
|
+
import { TransformStream, ReadableStream, WritableStream } from 'node:stream/web';
|
|
6
7
|
|
|
7
|
-
interface CommonOptions {
|
|
8
|
+
interface CommonOptions$1 {
|
|
8
9
|
input?: Readable;
|
|
9
10
|
output?: Writable;
|
|
10
11
|
signal?: AbortSignal;
|
|
@@ -12,7 +13,7 @@ interface CommonOptions {
|
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
type BoxAlignment = 'left' | 'center' | 'right';
|
|
15
|
-
interface BoxOptions extends CommonOptions {
|
|
16
|
+
interface BoxOptions extends CommonOptions$1 {
|
|
16
17
|
contentAlign?: BoxAlignment;
|
|
17
18
|
titleAlign?: BoxAlignment;
|
|
18
19
|
width?: number | 'auto';
|
|
@@ -22,7 +23,7 @@ interface BoxOptions extends CommonOptions {
|
|
|
22
23
|
formatBorder?: (text: string) => string;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
interface LogMessageOptions extends CommonOptions {
|
|
26
|
+
interface LogMessageOptions extends CommonOptions$1 {
|
|
26
27
|
symbol?: string;
|
|
27
28
|
spacing?: number;
|
|
28
29
|
secondarySymbol?: string;
|
|
@@ -196,225 +197,1569 @@ declare abstract class PromptProvider {
|
|
|
196
197
|
abstract taskLog(options: TaskLogOptions): TaskLogInstance;
|
|
197
198
|
}
|
|
198
199
|
|
|
199
|
-
type
|
|
200
|
+
type Not<Value extends boolean> = Value extends true ? false : true;
|
|
200
201
|
|
|
201
|
-
type
|
|
202
|
+
type And<First extends boolean, Second extends boolean> = First extends true ? Second : false;
|
|
203
|
+
|
|
204
|
+
type Or<First extends boolean, Second extends boolean> = First extends true ? true : Second;
|
|
205
|
+
|
|
206
|
+
type Unless<Condition extends boolean, ThenValue, ElseValue = never> = Condition extends true ? ElseValue : ThenValue;
|
|
207
|
+
|
|
208
|
+
type AndUnless<Condition extends boolean, ThenValue, ElseValue = unknown> = Condition extends true ? ElseValue : ThenValue;
|
|
209
|
+
|
|
210
|
+
// Whether any of T's union element is the same as one of U's union element.
|
|
211
|
+
// `&` does not work here.
|
|
212
|
+
type Intersects<T, U> = true extends (T extends U ? true : false) ? true : false;
|
|
213
|
+
|
|
214
|
+
// `options.std*: Generator`
|
|
215
|
+
// @todo Use `string`, `Uint8Array` or `unknown` for both the argument and the return type, based on whether `encoding: 'buffer'` and `objectMode: true` are used.
|
|
216
|
+
// See https://github.com/sindresorhus/execa/issues/694
|
|
217
|
+
type GeneratorTransform<IsSync extends boolean> = (chunk: unknown) =>
|
|
218
|
+
| Unless<IsSync, AsyncGenerator<unknown, void, void>>
|
|
219
|
+
| Generator<unknown, void, void>;
|
|
220
|
+
type GeneratorFinal<IsSync extends boolean> = () =>
|
|
221
|
+
| Unless<IsSync, AsyncGenerator<unknown, void, void>>
|
|
222
|
+
| Generator<unknown, void, void>;
|
|
223
|
+
|
|
224
|
+
type TransformCommon = {
|
|
202
225
|
/**
|
|
203
|
-
|
|
226
|
+
If `true`, allow `transformOptions.transform` and `transformOptions.final` to return any type, not just `string` or `Uint8Array`.
|
|
227
|
+
*/
|
|
228
|
+
readonly objectMode?: boolean;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
A transform or an array of transforms can be passed to the `stdin`, `stdout`, `stderr` or `stdio` option.
|
|
204
233
|
|
|
205
|
-
|
|
234
|
+
A transform is either a generator function or a plain object with the following members.
|
|
235
|
+
*/
|
|
236
|
+
type GeneratorTransformFull<IsSync extends boolean> = {
|
|
237
|
+
/**
|
|
238
|
+
Map or filter the input or output of the subprocess.
|
|
206
239
|
*/
|
|
207
|
-
|
|
240
|
+
readonly transform: GeneratorTransform<IsSync>;
|
|
208
241
|
|
|
209
242
|
/**
|
|
210
|
-
|
|
243
|
+
Create additional lines after the last one.
|
|
244
|
+
*/
|
|
245
|
+
readonly final?: GeneratorFinal<IsSync>;
|
|
211
246
|
|
|
212
|
-
|
|
213
|
-
|
|
247
|
+
/**
|
|
248
|
+
If `true`, iterate over arbitrary chunks of `Uint8Array`s instead of line `string`s.
|
|
214
249
|
*/
|
|
215
|
-
|
|
250
|
+
readonly binary?: boolean;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
If `true`, keep newlines in each `line` argument. Also, this allows multiple `yield`s to produces a single line.
|
|
254
|
+
*/
|
|
255
|
+
readonly preserveNewlines?: boolean;
|
|
256
|
+
} & TransformCommon;
|
|
257
|
+
|
|
258
|
+
// `options.std*: Duplex`
|
|
259
|
+
type DuplexTransform = {
|
|
260
|
+
readonly transform: Duplex;
|
|
261
|
+
} & TransformCommon;
|
|
262
|
+
|
|
263
|
+
// `options.std*: TransformStream`
|
|
264
|
+
type WebTransform = {
|
|
265
|
+
readonly transform: TransformStream;
|
|
266
|
+
} & TransformCommon;
|
|
267
|
+
|
|
268
|
+
type IsStandardStream<FdNumber extends string> = FdNumber extends keyof StandardStreams ? true : false;
|
|
269
|
+
|
|
270
|
+
type StandardStreams = readonly ['stdin', 'stdout', 'stderr'];
|
|
271
|
+
|
|
272
|
+
// When `options.stdin|stdout|stderr|stdio` is set to one of those values, no stream is created
|
|
273
|
+
type NoStreamStdioOption<FdNumber extends string> =
|
|
274
|
+
| 'ignore'
|
|
275
|
+
| 'inherit'
|
|
276
|
+
| 'ipc'
|
|
277
|
+
| number
|
|
278
|
+
| Readable
|
|
279
|
+
| Writable
|
|
280
|
+
| Unless<IsStandardStream<FdNumber>, undefined>
|
|
281
|
+
| readonly [NoStreamStdioOption<FdNumber>];
|
|
282
|
+
|
|
283
|
+
// `options.stdio` when it is not an array
|
|
284
|
+
type SimpleStdioOption<
|
|
285
|
+
IsSync extends boolean,
|
|
286
|
+
IsExtra extends boolean,
|
|
287
|
+
IsArray extends boolean,
|
|
288
|
+
> =
|
|
289
|
+
| undefined
|
|
290
|
+
| 'pipe'
|
|
291
|
+
| Unless<And<And<Not<IsSync>, IsArray>, IsExtra>, 'inherit'>
|
|
292
|
+
| Unless<IsArray, 'ignore'>
|
|
293
|
+
| Unless<IsSync, 'overlapped'>;
|
|
294
|
+
|
|
295
|
+
// Values available in both `options.stdin|stdio` and `options.stdout|stderr|stdio`
|
|
296
|
+
type CommonStdioOption<
|
|
297
|
+
IsSync extends boolean,
|
|
298
|
+
IsExtra extends boolean,
|
|
299
|
+
IsArray extends boolean,
|
|
300
|
+
> =
|
|
301
|
+
| SimpleStdioOption<IsSync, IsExtra, IsArray>
|
|
302
|
+
| URL
|
|
303
|
+
| {readonly file: string; readonly append?: boolean}
|
|
304
|
+
| GeneratorTransform<IsSync>
|
|
305
|
+
| GeneratorTransformFull<IsSync>
|
|
306
|
+
| Unless<And<Not<IsSync>, IsArray>, 3 | 4 | 5 | 6 | 7 | 8 | 9>
|
|
307
|
+
| Unless<Or<IsSync, IsArray>, 'ipc'>
|
|
308
|
+
| Unless<IsSync, DuplexTransform | WebTransform | TransformStream>;
|
|
309
|
+
|
|
310
|
+
// Synchronous iterables excluding strings, Uint8Arrays and Arrays
|
|
311
|
+
type IterableObject<IsArray extends boolean> = Iterable<unknown>
|
|
312
|
+
& object
|
|
313
|
+
& {readonly BYTES_PER_ELEMENT?: never}
|
|
314
|
+
& AndUnless<IsArray, {readonly lastIndexOf?: never}>;
|
|
315
|
+
|
|
316
|
+
// `process.stdin|stdout|stderr` are `Duplex` with a `fd` property.
|
|
317
|
+
// This ensures they can only be passed to `stdin`/`stdout`/`stderr`, based on their direction.
|
|
318
|
+
type ProcessStdinFd = {readonly fd?: 0};
|
|
319
|
+
type ProcessStdoutStderrFd = {readonly fd?: 1 | 2};
|
|
320
|
+
|
|
321
|
+
// Values available only in `options.stdin|stdio`
|
|
322
|
+
type InputStdioOption<
|
|
323
|
+
IsSync extends boolean = boolean,
|
|
324
|
+
IsExtra extends boolean = boolean,
|
|
325
|
+
IsArray extends boolean = boolean,
|
|
326
|
+
> =
|
|
327
|
+
| 0
|
|
328
|
+
| Unless<And<IsSync, IsExtra>, Uint8Array | IterableObject<IsArray>>
|
|
329
|
+
| Unless<And<IsSync, IsArray>, Readable & ProcessStdinFd>
|
|
330
|
+
| Unless<IsSync, (AsyncIterable<unknown> & ProcessStdinFd) | ReadableStream>;
|
|
331
|
+
|
|
332
|
+
// Values available only in `options.stdout|stderr|stdio`
|
|
333
|
+
type OutputStdioOption<
|
|
334
|
+
IsSync extends boolean,
|
|
335
|
+
IsArray extends boolean,
|
|
336
|
+
> =
|
|
337
|
+
| 1
|
|
338
|
+
| 2
|
|
339
|
+
| Unless<And<IsSync, IsArray>, Writable & ProcessStdoutStderrFd>
|
|
340
|
+
| Unless<IsSync, WritableStream>;
|
|
341
|
+
|
|
342
|
+
// `options.stdin` array items
|
|
343
|
+
type StdinSingleOption<
|
|
344
|
+
IsSync extends boolean,
|
|
345
|
+
IsExtra extends boolean,
|
|
346
|
+
IsArray extends boolean,
|
|
347
|
+
> =
|
|
348
|
+
| CommonStdioOption<IsSync, IsExtra, IsArray>
|
|
349
|
+
| InputStdioOption<IsSync, IsExtra, IsArray>;
|
|
350
|
+
|
|
351
|
+
// `options.stdin`
|
|
352
|
+
type StdinOptionCommon<
|
|
353
|
+
IsSync extends boolean = boolean,
|
|
354
|
+
IsExtra extends boolean = boolean,
|
|
355
|
+
> =
|
|
356
|
+
| StdinSingleOption<IsSync, IsExtra, false>
|
|
357
|
+
| ReadonlyArray<StdinSingleOption<IsSync, IsExtra, true>>;
|
|
358
|
+
|
|
359
|
+
// `options.stdout|stderr` array items
|
|
360
|
+
type StdoutStderrSingleOption<
|
|
361
|
+
IsSync extends boolean,
|
|
362
|
+
IsExtra extends boolean,
|
|
363
|
+
IsArray extends boolean,
|
|
364
|
+
> =
|
|
365
|
+
| CommonStdioOption<IsSync, IsExtra, IsArray>
|
|
366
|
+
| OutputStdioOption<IsSync, IsArray>;
|
|
367
|
+
|
|
368
|
+
// `options.stdout|stderr`
|
|
369
|
+
type StdoutStderrOptionCommon<
|
|
370
|
+
IsSync extends boolean = boolean,
|
|
371
|
+
IsExtra extends boolean = boolean,
|
|
372
|
+
> =
|
|
373
|
+
| StdoutStderrSingleOption<IsSync, IsExtra, false>
|
|
374
|
+
| ReadonlyArray<StdoutStderrSingleOption<IsSync, IsExtra, true>>;
|
|
375
|
+
|
|
376
|
+
// `options.stdio[3+]`
|
|
377
|
+
type StdioExtraOptionCommon<IsSync extends boolean> =
|
|
378
|
+
| StdinOptionCommon<IsSync, true>
|
|
379
|
+
| StdoutStderrOptionCommon<IsSync, true>;
|
|
380
|
+
|
|
381
|
+
// `options.stdin|stdout|stderr|stdio` array items
|
|
382
|
+
type StdioSingleOption<
|
|
383
|
+
IsSync extends boolean = boolean,
|
|
384
|
+
IsExtra extends boolean = boolean,
|
|
385
|
+
IsArray extends boolean = boolean,
|
|
386
|
+
> =
|
|
387
|
+
| StdinSingleOption<IsSync, IsExtra, IsArray>
|
|
388
|
+
| StdoutStderrSingleOption<IsSync, IsExtra, IsArray>;
|
|
389
|
+
|
|
390
|
+
// Get `options.stdin|stdout|stderr|stdio` items if it is an array, else keep as is
|
|
391
|
+
type StdioSingleOptionItems<StdioOptionType> = StdioOptionType extends readonly StdioSingleOption[]
|
|
392
|
+
? StdioOptionType[number]
|
|
393
|
+
: StdioOptionType;
|
|
394
|
+
|
|
395
|
+
// `options.stdin|stdout|stderr|stdio`
|
|
396
|
+
type StdioOptionCommon<IsSync extends boolean = boolean> =
|
|
397
|
+
| StdinOptionCommon<IsSync>
|
|
398
|
+
| StdoutStderrOptionCommon<IsSync>;
|
|
399
|
+
|
|
400
|
+
// `options.stdio` when it is an array
|
|
401
|
+
type StdioOptionsArray<IsSync extends boolean = boolean> = readonly [
|
|
402
|
+
StdinOptionCommon<IsSync, false>,
|
|
403
|
+
StdoutStderrOptionCommon<IsSync, false>,
|
|
404
|
+
StdoutStderrOptionCommon<IsSync, false>,
|
|
405
|
+
...ReadonlyArray<StdioExtraOptionCommon<IsSync>>,
|
|
406
|
+
];
|
|
407
|
+
|
|
408
|
+
// `options.stdio`
|
|
409
|
+
type StdioOptionsProperty<IsSync extends boolean = boolean> =
|
|
410
|
+
| SimpleStdioOption<IsSync, false, false>
|
|
411
|
+
| StdioOptionsArray<IsSync>;
|
|
412
|
+
|
|
413
|
+
// Message when the `serialization` option is `'advanced'`
|
|
414
|
+
type AdvancedMessage =
|
|
415
|
+
| string
|
|
416
|
+
| number
|
|
417
|
+
| boolean
|
|
418
|
+
| null
|
|
419
|
+
| object;
|
|
420
|
+
|
|
421
|
+
// Message when the `serialization` option is `'json'`
|
|
422
|
+
type JsonMessage =
|
|
423
|
+
| string
|
|
424
|
+
| number
|
|
425
|
+
| boolean
|
|
426
|
+
| null
|
|
427
|
+
| readonly JsonMessage[]
|
|
428
|
+
| {readonly [key: string | number]: JsonMessage};
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
Type of messages exchanged between a process and its subprocess using `sendMessage()`, `getOneMessage()` and `getEachMessage()`.
|
|
432
|
+
|
|
433
|
+
This requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.
|
|
434
|
+
*/
|
|
435
|
+
type Message<
|
|
436
|
+
Serialization extends Options['serialization'] = Options['serialization'],
|
|
437
|
+
> = Serialization extends 'json' ? JsonMessage : AdvancedMessage;
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
Options to `sendMessage()` and `subprocess.sendMessage()`
|
|
441
|
+
*/
|
|
442
|
+
type SendMessageOptions = {
|
|
443
|
+
/**
|
|
444
|
+
Throw when the other process is not receiving or listening to messages.
|
|
445
|
+
|
|
446
|
+
@default false
|
|
447
|
+
*/
|
|
448
|
+
readonly strict?: boolean;
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
Options to `getOneMessage()` and `subprocess.getOneMessage()`
|
|
453
|
+
*/
|
|
454
|
+
type GetOneMessageOptions<
|
|
455
|
+
Serialization extends Options['serialization'],
|
|
456
|
+
> = {
|
|
457
|
+
/**
|
|
458
|
+
Ignore any `message` that returns `false`.
|
|
459
|
+
*/
|
|
460
|
+
readonly filter?: (message: Message<Serialization>) => boolean;
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
Keep the subprocess alive while `getOneMessage()` is waiting.
|
|
464
|
+
|
|
465
|
+
@default true
|
|
466
|
+
*/
|
|
467
|
+
readonly reference?: boolean;
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
Options to `getEachMessage()` and `subprocess.getEachMessage()`
|
|
472
|
+
*/
|
|
473
|
+
type GetEachMessageOptions = {
|
|
474
|
+
/**
|
|
475
|
+
Keep the subprocess alive while `getEachMessage()` is waiting.
|
|
476
|
+
|
|
477
|
+
@default true
|
|
478
|
+
*/
|
|
479
|
+
readonly reference?: boolean;
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
// IPC methods in the subprocess
|
|
483
|
+
type IpcMethods<
|
|
484
|
+
IpcEnabled extends boolean,
|
|
485
|
+
Serialization extends Options['serialization'],
|
|
486
|
+
> = IpcEnabled extends true
|
|
487
|
+
? {
|
|
488
|
+
/**
|
|
489
|
+
Send a `message` to the subprocess.
|
|
490
|
+
|
|
491
|
+
This requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.
|
|
492
|
+
*/
|
|
493
|
+
sendMessage(message: Message<Serialization>, sendMessageOptions?: SendMessageOptions): Promise<void>;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
Receive a single `message` from the subprocess.
|
|
497
|
+
|
|
498
|
+
This requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.
|
|
499
|
+
*/
|
|
500
|
+
getOneMessage(getOneMessageOptions?: GetOneMessageOptions<Serialization>): Promise<Message<Serialization>>;
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
Iterate over each `message` from the subprocess.
|
|
504
|
+
|
|
505
|
+
This requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.
|
|
506
|
+
*/
|
|
507
|
+
getEachMessage(getEachMessageOptions?: GetEachMessageOptions): AsyncIterableIterator<Message<Serialization>>;
|
|
508
|
+
}
|
|
509
|
+
// Those methods only work if the `ipc` option is `true`.
|
|
510
|
+
// At runtime, they are actually defined, in order to provide with a nice error message.
|
|
511
|
+
// At type check time, they are typed as `undefined` to prevent calling them.
|
|
512
|
+
: {
|
|
513
|
+
sendMessage: undefined;
|
|
514
|
+
getOneMessage: undefined;
|
|
515
|
+
getEachMessage: undefined;
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
// Whether IPC is enabled, based on the `ipc`, `ipcInput` and `gracefulCancel` options
|
|
519
|
+
type HasIpc<OptionsType extends Options> = HasIpcOption<
|
|
520
|
+
OptionsType['ipc'],
|
|
521
|
+
'ipcInput' extends keyof OptionsType ? OptionsType['ipcInput'] : undefined,
|
|
522
|
+
'gracefulCancel' extends keyof OptionsType ? OptionsType['gracefulCancel'] : undefined
|
|
523
|
+
>;
|
|
524
|
+
|
|
525
|
+
type HasIpcOption<
|
|
526
|
+
IpcOption extends Options['ipc'],
|
|
527
|
+
IpcInputOption extends Options['ipcInput'],
|
|
528
|
+
GracefulCancelOption extends Options['gracefulCancel'],
|
|
529
|
+
> = IpcOption extends true
|
|
530
|
+
? true
|
|
531
|
+
: IpcOption extends false
|
|
532
|
+
? false
|
|
533
|
+
: IpcInputOption extends undefined
|
|
534
|
+
? GracefulCancelOption extends true
|
|
535
|
+
? true
|
|
536
|
+
: false
|
|
537
|
+
: true;
|
|
538
|
+
|
|
539
|
+
type FileDescriptorOption = `fd${number}`;
|
|
540
|
+
|
|
541
|
+
// `from` option of `subprocess.readable|duplex|iterable|pipe()`
|
|
542
|
+
// Also used by fd-specific options
|
|
543
|
+
type FromOption = 'stdout' | 'stderr' | 'all' | FileDescriptorOption;
|
|
544
|
+
|
|
545
|
+
// `to` option of `subprocess.writable|duplex|pipe()`
|
|
546
|
+
type ToOption = 'stdin' | FileDescriptorOption;
|
|
547
|
+
|
|
548
|
+
// Options which can be fd-specific like `{verbose: {stdout: 'none', stderr: 'full'}}`
|
|
549
|
+
type FdGenericOption<OptionType> = OptionType | GenericOptionObject<OptionType>;
|
|
550
|
+
|
|
551
|
+
type GenericOptionObject<OptionType> = {
|
|
552
|
+
readonly [FdName in GenericFromOption]?: OptionType
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
type GenericFromOption = FromOption | 'ipc';
|
|
556
|
+
|
|
557
|
+
// Retrieve fd-specific option's value
|
|
558
|
+
type FdSpecificOption<
|
|
559
|
+
GenericOption extends FdGenericOption<unknown>,
|
|
560
|
+
FdNumber extends string,
|
|
561
|
+
> = GenericOption extends GenericOptionObject<unknown>
|
|
562
|
+
? FdSpecificObjectOption<GenericOption, FdNumber>
|
|
563
|
+
: GenericOption;
|
|
564
|
+
|
|
565
|
+
type FdSpecificObjectOption<
|
|
566
|
+
GenericOption extends GenericOptionObject<unknown>,
|
|
567
|
+
FdNumber extends string,
|
|
568
|
+
> = keyof GenericOption extends GenericFromOption
|
|
569
|
+
? FdNumberToFromOption<FdNumber, keyof GenericOption> extends never
|
|
570
|
+
? undefined
|
|
571
|
+
: GenericOption[FdNumberToFromOption<FdNumber, keyof GenericOption>]
|
|
572
|
+
: GenericOption;
|
|
573
|
+
|
|
574
|
+
type FdNumberToFromOption<
|
|
575
|
+
FdNumber extends string,
|
|
576
|
+
GenericOptionKeys extends GenericFromOption,
|
|
577
|
+
> = FdNumber extends '1'
|
|
578
|
+
? 'stdout' extends GenericOptionKeys
|
|
579
|
+
? 'stdout'
|
|
580
|
+
: 'fd1' extends GenericOptionKeys
|
|
581
|
+
? 'fd1'
|
|
582
|
+
: 'all' extends GenericOptionKeys
|
|
583
|
+
? 'all'
|
|
584
|
+
: never
|
|
585
|
+
: FdNumber extends '2'
|
|
586
|
+
? 'stderr' extends GenericOptionKeys
|
|
587
|
+
? 'stderr'
|
|
588
|
+
: 'fd2' extends GenericOptionKeys
|
|
589
|
+
? 'fd2'
|
|
590
|
+
: 'all' extends GenericOptionKeys
|
|
591
|
+
? 'all'
|
|
592
|
+
: never
|
|
593
|
+
: `fd${FdNumber}` extends GenericOptionKeys
|
|
594
|
+
? `fd${FdNumber}`
|
|
595
|
+
: 'ipc' extends GenericOptionKeys
|
|
596
|
+
? 'ipc'
|
|
597
|
+
: never;
|
|
598
|
+
|
|
599
|
+
// `result.*` defined only on failure, i.e. on `error.*`
|
|
600
|
+
type ErrorProperties =
|
|
601
|
+
| 'name'
|
|
602
|
+
| 'message'
|
|
603
|
+
| 'stack'
|
|
604
|
+
| 'cause'
|
|
605
|
+
| 'shortMessage'
|
|
606
|
+
| 'originalMessage'
|
|
607
|
+
| 'code';
|
|
608
|
+
|
|
609
|
+
// `options.stdio`, normalized as an array
|
|
610
|
+
type StdioOptionNormalizedArray<OptionsType extends CommonOptions> = StdioOptionNormalized<OptionsType['stdio']>;
|
|
611
|
+
|
|
612
|
+
type StdioOptionNormalized<StdioOption extends CommonOptions['stdio']> = StdioOption extends StdioOptionsArray
|
|
613
|
+
? StdioOption
|
|
614
|
+
: StdioOption extends StdinOptionCommon
|
|
615
|
+
? StdioOption extends StdoutStderrOptionCommon
|
|
616
|
+
? readonly [StdioOption, StdioOption, StdioOption]
|
|
617
|
+
: DefaultStdioOption
|
|
618
|
+
: DefaultStdioOption;
|
|
619
|
+
|
|
620
|
+
// `options.stdio` default value
|
|
621
|
+
type DefaultStdioOption = readonly ['pipe', 'pipe', 'pipe'];
|
|
622
|
+
|
|
623
|
+
// `options.stdin|stdout|stderr|stdio` for a given file descriptor
|
|
624
|
+
type FdStdioOption<
|
|
625
|
+
FdNumber extends string,
|
|
626
|
+
OptionsType extends CommonOptions,
|
|
627
|
+
> = FdStdioOptionProperty<FdNumber, OptionsType>;
|
|
628
|
+
|
|
629
|
+
type FdStdioOptionProperty<
|
|
630
|
+
FdNumber extends string,
|
|
631
|
+
OptionsType extends CommonOptions,
|
|
632
|
+
> = string extends FdNumber ? StdioOptionCommon
|
|
633
|
+
: FdNumber extends keyof StandardStreams
|
|
634
|
+
? StandardStreams[FdNumber] extends keyof OptionsType
|
|
635
|
+
? OptionsType[StandardStreams[FdNumber]] extends undefined
|
|
636
|
+
? FdStdioArrayOption<FdNumber, OptionsType>
|
|
637
|
+
: OptionsType[StandardStreams[FdNumber]]
|
|
638
|
+
: FdStdioArrayOption<FdNumber, OptionsType>
|
|
639
|
+
: FdStdioArrayOption<FdNumber, OptionsType>;
|
|
640
|
+
|
|
641
|
+
// `options.stdio[FdNumber]`, excluding `options.stdin|stdout|stderr`
|
|
642
|
+
type FdStdioArrayOption<
|
|
643
|
+
FdNumber extends string,
|
|
644
|
+
OptionsType extends CommonOptions,
|
|
645
|
+
> = FdStdioArrayOptionProperty<FdNumber, StdioOptionNormalizedArray<OptionsType>>;
|
|
646
|
+
|
|
647
|
+
type FdStdioArrayOptionProperty<
|
|
648
|
+
FdNumber extends string,
|
|
649
|
+
StdioOptionsType,
|
|
650
|
+
> = string extends FdNumber
|
|
651
|
+
? StdioOptionCommon | undefined
|
|
652
|
+
: StdioOptionsType extends StdioOptionsArray
|
|
653
|
+
? FdNumber extends keyof StdioOptionsType
|
|
654
|
+
? StdioOptionsType[FdNumber]
|
|
655
|
+
: StdioOptionNormalizedArray<CommonOptions> extends StdioOptionsType
|
|
656
|
+
? StdioOptionsType[number]
|
|
657
|
+
: undefined
|
|
658
|
+
: undefined;
|
|
659
|
+
|
|
660
|
+
// Whether a file descriptor is in object mode
|
|
661
|
+
// I.e. whether `result.stdout|stderr|stdio|all` is an array of `unknown` due to `objectMode: true`
|
|
662
|
+
type IsObjectFd<
|
|
663
|
+
FdNumber extends string,
|
|
664
|
+
OptionsType extends CommonOptions,
|
|
665
|
+
> = IsObjectStdioOption<FdStdioOption<FdNumber, OptionsType>>;
|
|
666
|
+
|
|
667
|
+
type IsObjectStdioOption<StdioOptionType> = IsObjectStdioSingleOption<StdioSingleOptionItems<StdioOptionType>>;
|
|
668
|
+
|
|
669
|
+
type IsObjectStdioSingleOption<StdioSingleOptionType> = StdioSingleOptionType extends TransformCommon
|
|
670
|
+
? BooleanObjectMode<StdioSingleOptionType['objectMode']>
|
|
671
|
+
: StdioSingleOptionType extends DuplexTransform
|
|
672
|
+
? StdioSingleOptionType['transform']['readableObjectMode']
|
|
673
|
+
: false;
|
|
674
|
+
|
|
675
|
+
type BooleanObjectMode<ObjectModeOption extends boolean | undefined> = ObjectModeOption extends true ? true : false;
|
|
676
|
+
|
|
677
|
+
// Whether `result.stdio[FdNumber]` is an input stream
|
|
678
|
+
type IsInputFd<
|
|
679
|
+
FdNumber extends string,
|
|
680
|
+
OptionsType extends CommonOptions,
|
|
681
|
+
> = FdNumber extends '0'
|
|
682
|
+
? true
|
|
683
|
+
: Intersects<StdioSingleOptionItems<FdStdioArrayOption<FdNumber, OptionsType>>, InputStdioOption>;
|
|
684
|
+
|
|
685
|
+
// Whether `result.stdin|stdout|stderr|all|stdio[*]` is `undefined`
|
|
686
|
+
type IgnoresResultOutput<
|
|
687
|
+
FdNumber extends string,
|
|
688
|
+
OptionsType extends CommonOptions,
|
|
689
|
+
> = FdSpecificOption<OptionsType['buffer'], FdNumber> extends false
|
|
690
|
+
? true
|
|
691
|
+
: IsInputFd<FdNumber, OptionsType> extends true
|
|
692
|
+
? true
|
|
693
|
+
: IgnoresSubprocessOutput<FdNumber, OptionsType>;
|
|
694
|
+
|
|
695
|
+
// Whether `subprocess.stdout|stderr|all` is `undefined|null`
|
|
696
|
+
type IgnoresSubprocessOutput<
|
|
697
|
+
FdNumber extends string,
|
|
698
|
+
OptionsType extends CommonOptions,
|
|
699
|
+
> = IgnoresOutput<FdNumber, FdStdioOption<FdNumber, OptionsType>>;
|
|
700
|
+
|
|
701
|
+
type IgnoresOutput<
|
|
702
|
+
FdNumber extends string,
|
|
703
|
+
StdioOptionType,
|
|
704
|
+
> = StdioOptionType extends NoStreamStdioOption<FdNumber> ? true : false;
|
|
705
|
+
|
|
706
|
+
type DefaultEncodingOption = 'utf8';
|
|
707
|
+
type TextEncodingOption =
|
|
708
|
+
| DefaultEncodingOption
|
|
709
|
+
| 'utf16le';
|
|
710
|
+
|
|
711
|
+
type BufferEncodingOption = 'buffer';
|
|
712
|
+
type BinaryEncodingOption =
|
|
713
|
+
| BufferEncodingOption
|
|
714
|
+
| 'hex'
|
|
715
|
+
| 'base64'
|
|
716
|
+
| 'base64url'
|
|
717
|
+
| 'latin1'
|
|
718
|
+
| 'ascii';
|
|
719
|
+
|
|
720
|
+
// `options.encoding`
|
|
721
|
+
type EncodingOption =
|
|
722
|
+
| TextEncodingOption
|
|
723
|
+
| BinaryEncodingOption
|
|
724
|
+
| undefined;
|
|
725
|
+
|
|
726
|
+
// `result.stdout|stderr|stdio`
|
|
727
|
+
type ResultStdioNotAll<
|
|
728
|
+
FdNumber extends string,
|
|
729
|
+
OptionsType extends CommonOptions,
|
|
730
|
+
> = ResultStdio<FdNumber, FdNumber, FdNumber, OptionsType>;
|
|
731
|
+
|
|
732
|
+
// `result.stdout|stderr|stdio|all`
|
|
733
|
+
type ResultStdio<
|
|
734
|
+
MainFdNumber extends string,
|
|
735
|
+
ObjectFdNumber extends string,
|
|
736
|
+
LinesFdNumber extends string,
|
|
737
|
+
OptionsType extends CommonOptions,
|
|
738
|
+
> = ResultStdioProperty<
|
|
739
|
+
ObjectFdNumber,
|
|
740
|
+
LinesFdNumber,
|
|
741
|
+
IgnoresResultOutput<MainFdNumber, OptionsType>,
|
|
742
|
+
OptionsType
|
|
743
|
+
>;
|
|
744
|
+
|
|
745
|
+
type ResultStdioProperty<
|
|
746
|
+
ObjectFdNumber extends string,
|
|
747
|
+
LinesFdNumber extends string,
|
|
748
|
+
StreamOutputIgnored,
|
|
749
|
+
OptionsType extends CommonOptions,
|
|
750
|
+
> = StreamOutputIgnored extends true
|
|
751
|
+
? undefined
|
|
752
|
+
: ResultStdioItem<
|
|
753
|
+
IsObjectFd<ObjectFdNumber, OptionsType>,
|
|
754
|
+
FdSpecificOption<OptionsType['lines'], LinesFdNumber>,
|
|
755
|
+
OptionsType['encoding']
|
|
756
|
+
>;
|
|
757
|
+
|
|
758
|
+
type ResultStdioItem<
|
|
759
|
+
IsObjectResult,
|
|
760
|
+
LinesOption extends boolean | undefined,
|
|
761
|
+
Encoding extends CommonOptions['encoding'],
|
|
762
|
+
> = IsObjectResult extends true ? unknown[]
|
|
763
|
+
: Encoding extends BufferEncodingOption
|
|
764
|
+
? Uint8Array
|
|
765
|
+
: LinesOption extends true
|
|
766
|
+
? Encoding extends BinaryEncodingOption
|
|
767
|
+
? string
|
|
768
|
+
: string[]
|
|
769
|
+
: string;
|
|
770
|
+
|
|
771
|
+
// `result.all`
|
|
772
|
+
type ResultAll<OptionsType extends CommonOptions> =
|
|
773
|
+
ResultAllProperty<OptionsType['all'], OptionsType>;
|
|
774
|
+
|
|
775
|
+
type ResultAllProperty<
|
|
776
|
+
AllOption extends CommonOptions['all'],
|
|
777
|
+
OptionsType extends CommonOptions,
|
|
778
|
+
> = AllOption extends true
|
|
779
|
+
? ResultStdio<
|
|
780
|
+
AllMainFd<OptionsType>,
|
|
781
|
+
AllObjectFd<OptionsType>,
|
|
782
|
+
AllLinesFd<OptionsType>,
|
|
783
|
+
OptionsType
|
|
784
|
+
>
|
|
785
|
+
: undefined;
|
|
786
|
+
|
|
787
|
+
type AllMainFd<OptionsType extends CommonOptions> =
|
|
788
|
+
IgnoresResultOutput<'1', OptionsType> extends true ? '2' : '1';
|
|
789
|
+
|
|
790
|
+
type AllObjectFd<OptionsType extends CommonOptions> =
|
|
791
|
+
IsObjectFd<'1', OptionsType> extends true ? '1' : '2';
|
|
792
|
+
|
|
793
|
+
type AllLinesFd<OptionsType extends CommonOptions> =
|
|
794
|
+
FdSpecificOption<OptionsType['lines'], '1'> extends true ? '1' : '2';
|
|
795
|
+
|
|
796
|
+
// `result.stdio`
|
|
797
|
+
type ResultStdioArray<OptionsType extends CommonOptions> =
|
|
798
|
+
MapResultStdio<StdioOptionNormalizedArray<OptionsType>, OptionsType>;
|
|
799
|
+
|
|
800
|
+
type MapResultStdio<
|
|
801
|
+
StdioOptionsArrayType,
|
|
802
|
+
OptionsType extends CommonOptions,
|
|
803
|
+
> = {
|
|
804
|
+
-readonly [FdNumber in keyof StdioOptionsArrayType]: ResultStdioNotAll<
|
|
805
|
+
FdNumber extends string ? FdNumber : string,
|
|
806
|
+
OptionsType
|
|
807
|
+
>
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
// `result.ipcOutput`
|
|
811
|
+
// This is empty unless the `ipc` option is `true`.
|
|
812
|
+
// Also, this is empty if the `buffer` option is `false`.
|
|
813
|
+
type ResultIpcOutput<
|
|
814
|
+
IsSync,
|
|
815
|
+
OptionsType extends CommonOptions,
|
|
816
|
+
> = IsSync extends true
|
|
817
|
+
? []
|
|
818
|
+
: ResultIpcAsync<
|
|
819
|
+
FdSpecificOption<OptionsType['buffer'], 'ipc'>,
|
|
820
|
+
HasIpc<StricterOptions<OptionsType, Options>>,
|
|
821
|
+
OptionsType['serialization']
|
|
822
|
+
>;
|
|
823
|
+
|
|
824
|
+
type ResultIpcAsync<
|
|
825
|
+
BufferOption extends boolean | undefined,
|
|
826
|
+
IpcEnabled extends boolean,
|
|
827
|
+
SerializationOption extends CommonOptions['serialization'],
|
|
828
|
+
> = BufferOption extends false
|
|
829
|
+
? []
|
|
830
|
+
: IpcEnabled extends true
|
|
831
|
+
? Array<Message<SerializationOption>>
|
|
832
|
+
: [];
|
|
833
|
+
|
|
834
|
+
declare abstract class CommonResult<
|
|
835
|
+
IsSync extends boolean,
|
|
836
|
+
OptionsType extends CommonOptions,
|
|
837
|
+
> {
|
|
838
|
+
/**
|
|
839
|
+
The output of the subprocess on [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)).
|
|
840
|
+
|
|
841
|
+
This is `undefined` if the `stdout` option is set to only `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.
|
|
842
|
+
|
|
843
|
+
This is an array if the `lines` option is `true`, or if the `stdout` option is a transform in object mode.
|
|
844
|
+
*/
|
|
845
|
+
stdout: ResultStdioNotAll<'1', OptionsType>;
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
The output of the subprocess on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)).
|
|
849
|
+
|
|
850
|
+
This is `undefined` if the `stderr` option is set to only `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.
|
|
851
|
+
|
|
852
|
+
This is an array if the `lines` option is `true`, or if the `stderr` option is a transform in object mode.
|
|
853
|
+
*/
|
|
854
|
+
stderr: ResultStdioNotAll<'2', OptionsType>;
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
The output of the subprocess with `result.stdout` and `result.stderr` interleaved.
|
|
858
|
+
|
|
859
|
+
This requires the `all` option to be `true`.
|
|
860
|
+
|
|
861
|
+
This is `undefined` if both `stdout` and `stderr` options are set to only `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.
|
|
862
|
+
|
|
863
|
+
This is an array if the `lines` option is `true`, or if either the `stdout` or `stderr` option is a transform in object mode.
|
|
864
|
+
*/
|
|
865
|
+
all: ResultAll<OptionsType>;
|
|
216
866
|
|
|
217
867
|
/**
|
|
218
|
-
The
|
|
868
|
+
The output of the subprocess on `stdin`, `stdout`, `stderr` and other file descriptors.
|
|
869
|
+
|
|
870
|
+
Items are `undefined` when their corresponding `stdio` option is set to only `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.
|
|
871
|
+
|
|
872
|
+
Items are arrays when their corresponding `stdio` option is a transform in object mode.
|
|
219
873
|
*/
|
|
220
|
-
|
|
874
|
+
stdio: ResultStdioArray<OptionsType>;
|
|
221
875
|
|
|
222
876
|
/**
|
|
223
|
-
|
|
877
|
+
All the messages sent by the subprocess to the current process.
|
|
878
|
+
|
|
879
|
+
This is empty unless the `ipc` option is `true`. Also, this is empty if the `buffer` option is `false`.
|
|
224
880
|
*/
|
|
225
|
-
|
|
881
|
+
ipcOutput: ResultIpcOutput<IsSync, OptionsType>;
|
|
226
882
|
|
|
227
883
|
/**
|
|
228
|
-
|
|
884
|
+
Results of the other subprocesses that were piped into this subprocess.
|
|
885
|
+
|
|
886
|
+
This array is initially empty and is populated each time the `subprocess.pipe()` method resolves.
|
|
887
|
+
*/
|
|
888
|
+
pipedFrom: Unless<IsSync, Result[], []>;
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
The file and arguments that were run.
|
|
229
892
|
*/
|
|
230
|
-
|
|
893
|
+
command: string;
|
|
231
894
|
|
|
232
895
|
/**
|
|
233
|
-
|
|
896
|
+
Same as `command` but escaped.
|
|
897
|
+
*/
|
|
898
|
+
escapedCommand: string;
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
The current directory in which the command was run.
|
|
902
|
+
*/
|
|
903
|
+
cwd: string;
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
Duration of the subprocess, in milliseconds.
|
|
907
|
+
*/
|
|
908
|
+
durationMs: number;
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
Whether the subprocess failed to run.
|
|
912
|
+
|
|
913
|
+
When this is `true`, the result is an `ExecaError` instance with additional error-related properties.
|
|
234
914
|
*/
|
|
235
915
|
failed: boolean;
|
|
236
916
|
|
|
237
917
|
/**
|
|
238
|
-
Whether the
|
|
918
|
+
Whether the subprocess timed out due to the `timeout` option.
|
|
239
919
|
*/
|
|
240
920
|
timedOut: boolean;
|
|
241
921
|
|
|
242
922
|
/**
|
|
243
|
-
Whether the
|
|
923
|
+
Whether the subprocess was canceled using the `cancelSignal` option.
|
|
924
|
+
*/
|
|
925
|
+
isCanceled: boolean;
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
Whether the subprocess was canceled using both the `cancelSignal` and the `gracefulCancel` options.
|
|
929
|
+
*/
|
|
930
|
+
isGracefullyCanceled: boolean;
|
|
931
|
+
|
|
932
|
+
/**
|
|
933
|
+
Whether the subprocess failed because its output was larger than the `maxBuffer` option.
|
|
934
|
+
*/
|
|
935
|
+
isMaxBuffer: boolean;
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
Whether the subprocess was terminated by a signal (like `SIGTERM`) sent by either:
|
|
939
|
+
- The current process.
|
|
940
|
+
- Another process. This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).
|
|
941
|
+
*/
|
|
942
|
+
isTerminated: boolean;
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
Whether the subprocess was terminated by the `SIGKILL` signal sent by the `forceKillAfterDelay` option.
|
|
244
946
|
*/
|
|
245
|
-
|
|
947
|
+
isForcefullyTerminated: boolean;
|
|
246
948
|
|
|
247
949
|
/**
|
|
248
|
-
The
|
|
950
|
+
The numeric [exit code](https://en.wikipedia.org/wiki/Exit_status) of the subprocess that was run.
|
|
249
951
|
|
|
250
|
-
|
|
952
|
+
This is `undefined` when the subprocess could not be spawned or was terminated by a signal.
|
|
251
953
|
*/
|
|
252
|
-
|
|
954
|
+
exitCode?: number;
|
|
253
955
|
|
|
254
956
|
/**
|
|
255
|
-
|
|
957
|
+
The name of the signal (like `SIGTERM`) that terminated the subprocess, sent by either:
|
|
958
|
+
- The current process.
|
|
959
|
+
- Another process. This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).
|
|
256
960
|
|
|
257
|
-
If a signal terminated the
|
|
961
|
+
If a signal terminated the subprocess, this property is defined and included in the error message. Otherwise it is `undefined`.
|
|
962
|
+
*/
|
|
963
|
+
signal?: keyof SignalConstants;
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
A human-friendly description of the signal that was used to terminate the subprocess.
|
|
967
|
+
|
|
968
|
+
If a signal terminated the subprocess, 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.
|
|
258
969
|
*/
|
|
259
970
|
signalDescription?: string;
|
|
260
971
|
|
|
261
972
|
/**
|
|
262
|
-
|
|
973
|
+
Error message when the subprocess failed to run.
|
|
263
974
|
*/
|
|
264
|
-
|
|
975
|
+
message?: string;
|
|
976
|
+
|
|
977
|
+
/**
|
|
978
|
+
This is the same as `error.message` except it does not include the subprocess output.
|
|
979
|
+
*/
|
|
980
|
+
shortMessage?: string;
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
Original error message. This is the same as `error.message` excluding the subprocess output and some additional information added by Execa.
|
|
984
|
+
|
|
985
|
+
This exists only in specific instances, such as during a timeout.
|
|
986
|
+
*/
|
|
987
|
+
originalMessage?: string;
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
Underlying error, if there is one. For example, this is set by `subprocess.kill(error)`.
|
|
991
|
+
|
|
992
|
+
This is usually an `Error` instance.
|
|
993
|
+
*/
|
|
994
|
+
cause?: unknown;
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
Node.js-specific [error code](https://nodejs.org/api/errors.html#errorcode), when available.
|
|
998
|
+
*/
|
|
999
|
+
code?: string;
|
|
1000
|
+
|
|
1001
|
+
// We cannot `extend Error` because `message` must be optional. So we copy its types here.
|
|
1002
|
+
readonly name?: Error['name'];
|
|
1003
|
+
stack?: Error['stack'];
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
type SuccessResult<
|
|
1007
|
+
IsSync extends boolean = boolean,
|
|
1008
|
+
OptionsType extends CommonOptions = CommonOptions,
|
|
1009
|
+
> = InstanceType<typeof CommonResult<IsSync, OptionsType>> & OmitErrorIfReject<OptionsType['reject']>;
|
|
1010
|
+
|
|
1011
|
+
type OmitErrorIfReject<RejectOption extends CommonOptions['reject']> = {
|
|
1012
|
+
[ErrorProperty in ErrorProperties]: RejectOption extends false ? unknown : never
|
|
265
1013
|
};
|
|
266
1014
|
|
|
267
|
-
|
|
268
|
-
|
|
1015
|
+
/**
|
|
1016
|
+
Result of a subprocess successful execution.
|
|
1017
|
+
|
|
1018
|
+
When the subprocess fails, it is rejected with an `ExecaError` instead.
|
|
1019
|
+
*/
|
|
1020
|
+
type Result<OptionsType extends Options = Options> = SuccessResult<false, OptionsType>;
|
|
269
1021
|
|
|
270
1022
|
/**
|
|
271
|
-
Result of a
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
- its exit code is not `0`
|
|
275
|
-
- it was killed with a signal
|
|
276
|
-
- timing out
|
|
277
|
-
- being canceled
|
|
278
|
-
- there's not enough memory or there are already too many child processes
|
|
1023
|
+
Result of a subprocess successful execution.
|
|
1024
|
+
|
|
1025
|
+
When the subprocess fails, it is rejected with an `ExecaError` instead.
|
|
279
1026
|
*/
|
|
280
|
-
type
|
|
1027
|
+
type SyncResult<OptionsType extends SyncOptions = SyncOptions> = SuccessResult<true, OptionsType>;
|
|
1028
|
+
|
|
1029
|
+
type VerboseOption = FdGenericOption<
|
|
1030
|
+
| 'none'
|
|
1031
|
+
| 'short'
|
|
1032
|
+
| 'full'
|
|
1033
|
+
| VerboseFunction
|
|
1034
|
+
>;
|
|
1035
|
+
|
|
1036
|
+
type VerboseFunction = (verboseLine: string, verboseObject: MinimalVerboseObject) => string | void;
|
|
1037
|
+
|
|
1038
|
+
type GenericVerboseObject = {
|
|
281
1039
|
/**
|
|
282
|
-
|
|
1040
|
+
Event type. This can be:
|
|
1041
|
+
- `'command'`: subprocess start
|
|
1042
|
+
- `'output'`: `stdout`/`stderr` output
|
|
1043
|
+
- `'ipc'`: IPC output
|
|
1044
|
+
- `'error'`: subprocess failure
|
|
1045
|
+
- `'duration'`: subprocess success or failure
|
|
1046
|
+
*/
|
|
1047
|
+
type: 'command' | 'output' | 'ipc' | 'error' | 'duration';
|
|
283
1048
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
- `
|
|
1049
|
+
/**
|
|
1050
|
+
Depending on `verboseObject.type`, this is:
|
|
1051
|
+
- `'command'`: the `result.escapedCommand`
|
|
1052
|
+
- `'output'`: one line from `result.stdout` or `result.stderr`
|
|
1053
|
+
- `'ipc'`: one IPC message from `result.ipcOutput`
|
|
1054
|
+
- `'error'`: the `error.shortMessage`
|
|
1055
|
+
- `'duration'`: the `result.durationMs`
|
|
287
1056
|
*/
|
|
288
|
-
|
|
1057
|
+
message: string;
|
|
1058
|
+
|
|
1059
|
+
/**
|
|
1060
|
+
The file and arguments that were run. This is the same as `result.escapedCommand`.
|
|
1061
|
+
*/
|
|
1062
|
+
escapedCommand: string;
|
|
289
1063
|
|
|
290
1064
|
/**
|
|
291
|
-
|
|
1065
|
+
Serial number identifying the subprocess within the current process. It is incremented from `'0'`.
|
|
1066
|
+
|
|
1067
|
+
This is helpful when multiple subprocesses are running at the same time.
|
|
292
1068
|
|
|
293
|
-
|
|
1069
|
+
This is similar to a [PID](https://en.wikipedia.org/wiki/Process_identifier) except it has no maximum limit, which means it never repeats. Also, it is usually shorter.
|
|
294
1070
|
*/
|
|
295
|
-
|
|
296
|
-
} & ExecaSyncReturnValue<StdoutStderrType>;
|
|
1071
|
+
commandId: string;
|
|
297
1072
|
|
|
298
|
-
type ExecaSyncError<StdoutStderrType extends StdoutStderrAll = string> = {
|
|
299
1073
|
/**
|
|
300
|
-
|
|
1074
|
+
Event date/time.
|
|
1075
|
+
*/
|
|
1076
|
+
timestamp: Date;
|
|
301
1077
|
|
|
302
|
-
|
|
1078
|
+
/**
|
|
1079
|
+
Whether another subprocess is piped into this subprocess. This is `false` when `result.pipedFrom` is empty.
|
|
303
1080
|
*/
|
|
304
|
-
|
|
1081
|
+
piped: boolean;
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1084
|
+
type MinimalVerboseObject = GenericVerboseObject & {
|
|
1085
|
+
// We cannot use the `CommonOptions` type because it would make this type recursive
|
|
1086
|
+
options: object;
|
|
1087
|
+
result?: never;
|
|
1088
|
+
};
|
|
305
1089
|
|
|
1090
|
+
type CommonOptions<IsSync extends boolean = boolean> = {
|
|
306
1091
|
/**
|
|
307
|
-
|
|
1092
|
+
Prefer locally installed binaries when looking for a binary to execute.
|
|
1093
|
+
|
|
1094
|
+
@default `true` with `$`, `false` otherwise
|
|
308
1095
|
*/
|
|
309
|
-
|
|
1096
|
+
readonly preferLocal?: boolean;
|
|
310
1097
|
|
|
311
1098
|
/**
|
|
312
|
-
|
|
1099
|
+
Preferred path to find locally installed binaries, when using the `preferLocal` option.
|
|
313
1100
|
|
|
314
|
-
|
|
1101
|
+
@default `cwd` option
|
|
315
1102
|
*/
|
|
316
|
-
|
|
317
|
-
|
|
1103
|
+
readonly localDir?: string | URL;
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
If `true`, runs with Node.js. The first argument must be a Node.js file.
|
|
1107
|
+
|
|
1108
|
+
The subprocess inherits the current Node.js [CLI flags](https://nodejs.org/api/cli.html#options) and version. This can be overridden using the `nodeOptions` and `nodePath` options.
|
|
1109
|
+
|
|
1110
|
+
@default `true` with `execaNode()`, `false` otherwise
|
|
1111
|
+
*/
|
|
1112
|
+
readonly node?: boolean;
|
|
318
1113
|
|
|
319
|
-
type ExecaError<StdoutStderrType extends StdoutStderrAll = string> = {
|
|
320
1114
|
/**
|
|
321
|
-
|
|
1115
|
+
List of [CLI flags](https://nodejs.org/api/cli.html#cli_options) passed to the Node.js executable.
|
|
322
1116
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
1117
|
+
Requires the `node` option to be `true`.
|
|
1118
|
+
|
|
1119
|
+
@default [`process.execArgv`](https://nodejs.org/api/process.html#process_process_execargv) (current Node.js CLI flags)
|
|
326
1120
|
*/
|
|
327
|
-
|
|
1121
|
+
readonly nodeOptions?: readonly string[];
|
|
328
1122
|
|
|
329
1123
|
/**
|
|
330
|
-
|
|
1124
|
+
Path to the Node.js executable.
|
|
1125
|
+
|
|
1126
|
+
Requires the `node` option to be `true`.
|
|
1127
|
+
|
|
1128
|
+
@default [`process.execPath`](https://nodejs.org/api/process.html#process_process_execpath) (current Node.js executable)
|
|
331
1129
|
*/
|
|
332
|
-
|
|
333
|
-
|
|
1130
|
+
readonly nodePath?: string | URL;
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
If `true`, runs the command inside of a [shell](https://en.wikipedia.org/wiki/Shell_(computing)).
|
|
1134
|
+
|
|
1135
|
+
Uses [`/bin/sh`](https://en.wikipedia.org/wiki/Unix_shell) on UNIX and [`cmd.exe`](https://en.wikipedia.org/wiki/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.
|
|
1136
|
+
|
|
1137
|
+
We recommend against using this option.
|
|
1138
|
+
|
|
1139
|
+
@default false
|
|
1140
|
+
*/
|
|
1141
|
+
readonly shell?: boolean | string | URL;
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
Current [working directory](https://en.wikipedia.org/wiki/Working_directory) of the subprocess.
|
|
1145
|
+
|
|
1146
|
+
This is also used to resolve the `nodePath` option when it is a relative path.
|
|
1147
|
+
|
|
1148
|
+
@default process.cwd()
|
|
1149
|
+
*/
|
|
1150
|
+
readonly cwd?: string | URL;
|
|
334
1151
|
|
|
335
|
-
type KillOptions = {
|
|
336
1152
|
/**
|
|
337
|
-
|
|
1153
|
+
[Environment variables](https://en.wikipedia.org/wiki/Environment_variable).
|
|
338
1154
|
|
|
339
|
-
|
|
1155
|
+
Unless the `extendEnv` option is `false`, the subprocess also uses the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).
|
|
1156
|
+
|
|
1157
|
+
@default [process.env](https://nodejs.org/api/process.html#processenv)
|
|
1158
|
+
*/
|
|
1159
|
+
readonly env?: Readonly<Partial<Record<string, string>>>;
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
If `true`, the subprocess uses both the `env` option and the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).
|
|
1163
|
+
If `false`, only the `env` option is used, not `process.env`.
|
|
1164
|
+
|
|
1165
|
+
@default true
|
|
1166
|
+
*/
|
|
1167
|
+
readonly extendEnv?: boolean;
|
|
1168
|
+
|
|
1169
|
+
/**
|
|
1170
|
+
Write some input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).
|
|
1171
|
+
|
|
1172
|
+
See also the `inputFile` and `stdin` options.
|
|
1173
|
+
*/
|
|
1174
|
+
readonly input?: string | Uint8Array | Readable;
|
|
1175
|
+
|
|
1176
|
+
/**
|
|
1177
|
+
Use a file as input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).
|
|
1178
|
+
|
|
1179
|
+
See also the `input` and `stdin` options.
|
|
1180
|
+
*/
|
|
1181
|
+
readonly inputFile?: string | URL;
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
How to setup the subprocess' [standard input](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)). This can be `'pipe'`, `'overlapped'`, `'ignore`, `'inherit'`, a file descriptor integer, a Node.js `Readable` stream, a web `ReadableStream`, a `{ file: 'path' }` object, a file URL, an `Iterable`, an `AsyncIterable`, an `Uint8Array`, a generator function, a `Duplex` or a web `TransformStream`.
|
|
1185
|
+
|
|
1186
|
+
This can be an array of values such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.
|
|
1187
|
+
|
|
1188
|
+
@default `'inherit'` with `$`, `'pipe'` otherwise
|
|
1189
|
+
*/
|
|
1190
|
+
readonly stdin?: StdinOptionCommon<IsSync>;
|
|
1191
|
+
|
|
1192
|
+
/**
|
|
1193
|
+
How to setup the subprocess' [standard output](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)). This can be `'pipe'`, `'overlapped'`, `'ignore`, `'inherit'`, a file descriptor integer, a Node.js `Writable` stream, a web `WritableStream`, a `{ file: 'path' }` object, a file URL, a generator function, a `Duplex` or a web `TransformStream`.
|
|
1194
|
+
|
|
1195
|
+
This can be an array of values such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.
|
|
1196
|
+
|
|
1197
|
+
@default 'pipe'
|
|
1198
|
+
*/
|
|
1199
|
+
readonly stdout?: StdoutStderrOptionCommon<IsSync>;
|
|
1200
|
+
|
|
1201
|
+
/**
|
|
1202
|
+
How to setup the subprocess' [standard error](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)). This can be `'pipe'`, `'overlapped'`, `'ignore`, `'inherit'`, a file descriptor integer, a Node.js `Writable` stream, a web `WritableStream`, a `{ file: 'path' }` object, a file URL, a generator function, a `Duplex` or a web `TransformStream`.
|
|
1203
|
+
|
|
1204
|
+
This can be an array of values such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.
|
|
1205
|
+
|
|
1206
|
+
@default 'pipe'
|
|
1207
|
+
*/
|
|
1208
|
+
readonly stderr?: StdoutStderrOptionCommon<IsSync>;
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
Like the `stdin`, `stdout` and `stderr` options but for all [file descriptors](https://en.wikipedia.org/wiki/File_descriptor) at once. For example, `{stdio: ['ignore', 'pipe', 'pipe']}` is the same as `{stdin: 'ignore', stdout: 'pipe', stderr: 'pipe'}`.
|
|
1212
|
+
|
|
1213
|
+
A single string can be used as a shortcut.
|
|
1214
|
+
|
|
1215
|
+
The array can have more than 3 items, to create additional file descriptors beyond `stdin`/`stdout`/`stderr`.
|
|
1216
|
+
|
|
1217
|
+
@default 'pipe'
|
|
1218
|
+
*/
|
|
1219
|
+
readonly stdio?: StdioOptionsProperty<IsSync>;
|
|
1220
|
+
|
|
1221
|
+
/**
|
|
1222
|
+
Add a `subprocess.all` stream and a `result.all` property. They contain the combined/interleaved output of the subprocess' `stdout` and `stderr`.
|
|
1223
|
+
|
|
1224
|
+
@default false
|
|
1225
|
+
*/
|
|
1226
|
+
readonly all?: boolean;
|
|
1227
|
+
|
|
1228
|
+
/**
|
|
1229
|
+
If the subprocess outputs text, specifies its character encoding, either [`'utf8'`](https://en.wikipedia.org/wiki/UTF-8) or [`'utf16le'`](https://en.wikipedia.org/wiki/UTF-16).
|
|
1230
|
+
|
|
1231
|
+
If it outputs binary data instead, this should be either:
|
|
1232
|
+
- `'buffer'`: returns the binary output as an `Uint8Array`.
|
|
1233
|
+
- [`'hex'`](https://en.wikipedia.org/wiki/Hexadecimal), [`'base64'`](https://en.wikipedia.org/wiki/Base64), [`'base64url'`](https://en.wikipedia.org/wiki/Base64#URL_applications), [`'latin1'`](https://nodejs.org/api/buffer.html#buffers-and-character-encodings) or [`'ascii'`](https://nodejs.org/api/buffer.html#buffers-and-character-encodings): encodes the binary output as a string.
|
|
1234
|
+
|
|
1235
|
+
The output is available with `result.stdout`, `result.stderr` and `result.stdio`.
|
|
1236
|
+
|
|
1237
|
+
@default 'utf8'
|
|
1238
|
+
*/
|
|
1239
|
+
readonly encoding?: EncodingOption;
|
|
1240
|
+
|
|
1241
|
+
/**
|
|
1242
|
+
Set `result.stdout`, `result.stderr`, `result.all` and `result.stdio` as arrays of strings, splitting the subprocess' output into lines.
|
|
1243
|
+
|
|
1244
|
+
This cannot be used if the `encoding` option is binary.
|
|
1245
|
+
|
|
1246
|
+
By default, this applies to both `stdout` and `stderr`, but different values can also be passed.
|
|
1247
|
+
|
|
1248
|
+
@default false
|
|
1249
|
+
*/
|
|
1250
|
+
readonly lines?: FdGenericOption<boolean>;
|
|
1251
|
+
|
|
1252
|
+
/**
|
|
1253
|
+
Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.
|
|
1254
|
+
|
|
1255
|
+
If the `lines` option is true, this applies to each output line instead.
|
|
1256
|
+
|
|
1257
|
+
By default, this applies to both `stdout` and `stderr`, but different values can also be passed.
|
|
1258
|
+
|
|
1259
|
+
@default true
|
|
1260
|
+
*/
|
|
1261
|
+
readonly stripFinalNewline?: FdGenericOption<boolean>;
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
Largest amount of data allowed on `stdout`, `stderr` and `stdio`.
|
|
1265
|
+
|
|
1266
|
+
By default, this applies to both `stdout` and `stderr`, but different values can also be passed.
|
|
1267
|
+
|
|
1268
|
+
When reached, `error.isMaxBuffer` becomes `true`.
|
|
1269
|
+
|
|
1270
|
+
@default 100_000_000
|
|
1271
|
+
*/
|
|
1272
|
+
readonly maxBuffer?: FdGenericOption<number>;
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
When `buffer` is `false`, the `result.stdout`, `result.stderr`, `result.all` and `result.stdio` properties are not set.
|
|
1276
|
+
|
|
1277
|
+
By default, this applies to both `stdout` and `stderr`, but different values can also be passed.
|
|
1278
|
+
|
|
1279
|
+
@default true
|
|
1280
|
+
*/
|
|
1281
|
+
readonly buffer?: FdGenericOption<boolean>;
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
Enables exchanging messages with the subprocess using `subprocess.sendMessage(message)`, `subprocess.getOneMessage()` and `subprocess.getEachMessage()`.
|
|
1285
|
+
|
|
1286
|
+
The subprocess must be a Node.js file.
|
|
1287
|
+
|
|
1288
|
+
@default `true` if the `node`, `ipcInput` or `gracefulCancel` option is set, `false` otherwise
|
|
1289
|
+
*/
|
|
1290
|
+
readonly ipc?: Unless<IsSync, boolean>;
|
|
1291
|
+
|
|
1292
|
+
/**
|
|
1293
|
+
Specify the kind of serialization used for sending messages between subprocesses when using the `ipc` option.
|
|
1294
|
+
|
|
1295
|
+
@default 'advanced'
|
|
1296
|
+
*/
|
|
1297
|
+
readonly serialization?: Unless<IsSync, 'json' | 'advanced'>;
|
|
1298
|
+
|
|
1299
|
+
/**
|
|
1300
|
+
Sends an IPC message when the subprocess starts.
|
|
1301
|
+
|
|
1302
|
+
The subprocess must be a Node.js file. The value's type depends on the `serialization` option.
|
|
1303
|
+
*/
|
|
1304
|
+
readonly ipcInput?: Unless<IsSync, Message>;
|
|
1305
|
+
|
|
1306
|
+
/**
|
|
1307
|
+
If `verbose` is `'short'`, prints the command on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)): its file, arguments, duration and (if it failed) error message.
|
|
1308
|
+
|
|
1309
|
+
If `verbose` is `'full'` or a function, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)), `stderr` and IPC messages are also printed.
|
|
1310
|
+
|
|
1311
|
+
A function can be passed to customize logging.
|
|
1312
|
+
|
|
1313
|
+
By default, this applies to both `stdout` and `stderr`, but different values can also be passed.
|
|
1314
|
+
|
|
1315
|
+
@default 'none'
|
|
1316
|
+
*/
|
|
1317
|
+
readonly verbose?: VerboseOption;
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
Setting this to `false` resolves the result's promise with the error instead of rejecting it.
|
|
1321
|
+
|
|
1322
|
+
@default true
|
|
1323
|
+
*/
|
|
1324
|
+
readonly reject?: boolean;
|
|
1325
|
+
|
|
1326
|
+
/**
|
|
1327
|
+
If `timeout` is greater than `0`, the subprocess will be terminated if it runs for longer than that amount of milliseconds.
|
|
1328
|
+
|
|
1329
|
+
On timeout, `error.timedOut` becomes `true`.
|
|
1330
|
+
|
|
1331
|
+
@default 0
|
|
1332
|
+
*/
|
|
1333
|
+
readonly timeout?: number;
|
|
1334
|
+
|
|
1335
|
+
/**
|
|
1336
|
+
When the `cancelSignal` is [aborted](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort), terminate the subprocess using a `SIGTERM` signal.
|
|
1337
|
+
|
|
1338
|
+
When aborted, `error.isCanceled` becomes `true`.
|
|
1339
|
+
|
|
1340
|
+
@example
|
|
1341
|
+
```
|
|
1342
|
+
import {execaNode} from 'execa';
|
|
1343
|
+
|
|
1344
|
+
const controller = new AbortController();
|
|
1345
|
+
const cancelSignal = controller.signal;
|
|
1346
|
+
|
|
1347
|
+
setTimeout(() => {
|
|
1348
|
+
controller.abort();
|
|
1349
|
+
}, 5000);
|
|
1350
|
+
|
|
1351
|
+
try {
|
|
1352
|
+
await execaNode({cancelSignal})`build.js`;
|
|
1353
|
+
} catch (error) {
|
|
1354
|
+
if (error.isCanceled) {
|
|
1355
|
+
console.error('Canceled by cancelSignal.');
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
throw error;
|
|
1359
|
+
}
|
|
1360
|
+
```
|
|
1361
|
+
*/
|
|
1362
|
+
readonly cancelSignal?: Unless<IsSync, AbortSignal>;
|
|
1363
|
+
|
|
1364
|
+
/**
|
|
1365
|
+
When the `cancelSignal` option is [aborted](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort), do not send any `SIGTERM`. Instead, abort the [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) returned by `getCancelSignal()`. The subprocess should use it to terminate gracefully.
|
|
1366
|
+
|
|
1367
|
+
The subprocess must be a Node.js file.
|
|
1368
|
+
|
|
1369
|
+
When aborted, `error.isGracefullyCanceled` becomes `true`.
|
|
1370
|
+
|
|
1371
|
+
@default false
|
|
1372
|
+
*/
|
|
1373
|
+
readonly gracefulCancel?: Unless<IsSync, boolean>;
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
If the subprocess is terminated but does not exit, forcefully exit it by sending [`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL).
|
|
1377
|
+
|
|
1378
|
+
When this happens, `error.isForcefullyTerminated` becomes `true`.
|
|
340
1379
|
|
|
341
1380
|
@default 5000
|
|
342
1381
|
*/
|
|
343
|
-
|
|
1382
|
+
readonly forceKillAfterDelay?: Unless<IsSync, number | boolean>;
|
|
1383
|
+
|
|
1384
|
+
/**
|
|
1385
|
+
Default [signal](https://en.wikipedia.org/wiki/Signal_(IPC)) used to terminate the subprocess.
|
|
1386
|
+
|
|
1387
|
+
This can be either a name (like `'SIGTERM'`) or a number (like `9`).
|
|
1388
|
+
|
|
1389
|
+
@default 'SIGTERM'
|
|
1390
|
+
*/
|
|
1391
|
+
readonly killSignal?: keyof SignalConstants | number;
|
|
1392
|
+
|
|
1393
|
+
/**
|
|
1394
|
+
Run the subprocess independently from the current process.
|
|
1395
|
+
|
|
1396
|
+
@default false
|
|
1397
|
+
*/
|
|
1398
|
+
readonly detached?: Unless<IsSync, boolean>;
|
|
1399
|
+
|
|
1400
|
+
/**
|
|
1401
|
+
Kill the subprocess when the current process exits.
|
|
1402
|
+
|
|
1403
|
+
@default true
|
|
1404
|
+
*/
|
|
1405
|
+
readonly cleanup?: Unless<IsSync, boolean>;
|
|
1406
|
+
|
|
1407
|
+
/**
|
|
1408
|
+
Sets the [user identifier](https://en.wikipedia.org/wiki/User_identifier) of the subprocess.
|
|
1409
|
+
|
|
1410
|
+
@default current user identifier
|
|
1411
|
+
*/
|
|
1412
|
+
readonly uid?: number;
|
|
1413
|
+
|
|
1414
|
+
/**
|
|
1415
|
+
Sets the [group identifier](https://en.wikipedia.org/wiki/Group_identifier) of the subprocess.
|
|
1416
|
+
|
|
1417
|
+
@default current group identifier
|
|
1418
|
+
*/
|
|
1419
|
+
readonly gid?: number;
|
|
1420
|
+
|
|
1421
|
+
/**
|
|
1422
|
+
Value of [`argv[0]`](https://nodejs.org/api/process.html#processargv0) sent to the subprocess.
|
|
1423
|
+
|
|
1424
|
+
@default file being executed
|
|
1425
|
+
*/
|
|
1426
|
+
readonly argv0?: string;
|
|
1427
|
+
|
|
1428
|
+
/**
|
|
1429
|
+
On Windows, do not create a new console window.
|
|
1430
|
+
|
|
1431
|
+
@default true
|
|
1432
|
+
*/
|
|
1433
|
+
readonly windowsHide?: boolean;
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
If `false`, escapes the command arguments on Windows.
|
|
1437
|
+
|
|
1438
|
+
@default `true` if the `shell` option is `true`, `false` otherwise
|
|
1439
|
+
*/
|
|
1440
|
+
readonly windowsVerbatimArguments?: boolean;
|
|
344
1441
|
};
|
|
345
1442
|
|
|
346
|
-
|
|
1443
|
+
/**
|
|
1444
|
+
Subprocess options.
|
|
1445
|
+
|
|
1446
|
+
Some options are related to the subprocess output: `verbose`, `lines`, `stripFinalNewline`, `buffer`, `maxBuffer`. By default, those options apply to all file descriptors (`stdout`, `stderr`, etc.). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `all` (both stdout and stderr), `ipc`, `fd3`, etc.
|
|
1447
|
+
|
|
1448
|
+
@example
|
|
1449
|
+
|
|
1450
|
+
```
|
|
1451
|
+
// Same value for stdout and stderr
|
|
1452
|
+
await execa({verbose: 'full'})`npm run build`;
|
|
1453
|
+
|
|
1454
|
+
// Different values for stdout and stderr
|
|
1455
|
+
await execa({verbose: {stdout: 'none', stderr: 'full'}})`npm run build`;
|
|
1456
|
+
```
|
|
1457
|
+
*/
|
|
1458
|
+
type Options = CommonOptions<false>;
|
|
1459
|
+
|
|
1460
|
+
/**
|
|
1461
|
+
Subprocess options, with synchronous methods.
|
|
1462
|
+
|
|
1463
|
+
Some options are related to the subprocess output: `verbose`, `lines`, `stripFinalNewline`, `buffer`, `maxBuffer`. By default, those options apply to all file descriptors (`stdout`, `stderr`, etc.). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `all` (both stdout and stderr), `ipc`, `fd3`, etc.
|
|
1464
|
+
|
|
1465
|
+
@example
|
|
1466
|
+
|
|
1467
|
+
```
|
|
1468
|
+
// Same value for stdout and stderr
|
|
1469
|
+
execaSync({verbose: 'full'})`npm run build`;
|
|
1470
|
+
|
|
1471
|
+
// Different values for stdout and stderr
|
|
1472
|
+
execaSync({verbose: {stdout: 'none', stderr: 'full'}})`npm run build`;
|
|
1473
|
+
```
|
|
1474
|
+
*/
|
|
1475
|
+
type SyncOptions = CommonOptions<true>;
|
|
1476
|
+
|
|
1477
|
+
type StricterOptions<
|
|
1478
|
+
WideOptions extends CommonOptions,
|
|
1479
|
+
StrictOptions extends CommonOptions,
|
|
1480
|
+
> = WideOptions extends StrictOptions ? WideOptions : StrictOptions;
|
|
1481
|
+
|
|
1482
|
+
type TemplateExpressionItem =
|
|
1483
|
+
| string
|
|
1484
|
+
| number
|
|
1485
|
+
| Result
|
|
1486
|
+
| SyncResult;
|
|
1487
|
+
|
|
1488
|
+
/**
|
|
1489
|
+
Value allowed inside `${...}` when using the template string syntax.
|
|
1490
|
+
*/
|
|
1491
|
+
type TemplateExpression = TemplateExpressionItem | readonly TemplateExpressionItem[];
|
|
1492
|
+
|
|
1493
|
+
// `subprocess.pipe()` options
|
|
1494
|
+
type PipeOptions = {
|
|
347
1495
|
/**
|
|
348
|
-
|
|
1496
|
+
Which stream to pipe from the source subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.
|
|
349
1497
|
|
|
350
|
-
This
|
|
351
|
-
- the `all` option is `false` (the default value)
|
|
352
|
-
- 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)
|
|
1498
|
+
`"all"` pipes both `stdout` and `stderr`. This requires the `all` option to be `true`.
|
|
353
1499
|
*/
|
|
354
|
-
|
|
1500
|
+
readonly from?: FromOption;
|
|
355
1501
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
1502
|
+
/**
|
|
1503
|
+
Which stream to pipe to the destination subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.
|
|
1504
|
+
*/
|
|
1505
|
+
readonly to?: ToOption;
|
|
359
1506
|
|
|
360
1507
|
/**
|
|
361
|
-
|
|
1508
|
+
Unpipe the subprocess when the signal aborts.
|
|
362
1509
|
*/
|
|
363
|
-
|
|
1510
|
+
readonly unpipeSignal?: AbortSignal;
|
|
1511
|
+
};
|
|
364
1512
|
|
|
1513
|
+
// `subprocess.pipe()`
|
|
1514
|
+
type PipableSubprocess = {
|
|
365
1515
|
/**
|
|
366
|
-
|
|
1516
|
+
[Pipe](https://nodejs.org/api/stream.html#readablepipedestination-options) the subprocess' `stdout` to a second Execa subprocess' `stdin`. This resolves with that second subprocess' result. If either subprocess is rejected, this is rejected with that subprocess' error instead.
|
|
1517
|
+
|
|
1518
|
+
This follows the same syntax as `execa(file, arguments?, options?)` except both regular options and pipe-specific options can be specified.
|
|
367
1519
|
*/
|
|
368
|
-
|
|
1520
|
+
pipe<OptionsType extends Options & PipeOptions = {}>(
|
|
1521
|
+
file: string | URL,
|
|
1522
|
+
arguments?: readonly string[],
|
|
1523
|
+
options?: OptionsType,
|
|
1524
|
+
): Promise<Result<OptionsType>> & PipableSubprocess;
|
|
1525
|
+
pipe<OptionsType extends Options & PipeOptions = {}>(
|
|
1526
|
+
file: string | URL,
|
|
1527
|
+
options?: OptionsType,
|
|
1528
|
+
): Promise<Result<OptionsType>> & PipableSubprocess;
|
|
369
1529
|
|
|
370
1530
|
/**
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
1531
|
+
Like `subprocess.pipe(file, arguments?, options?)` but using a `command` template string instead. This follows the same syntax as `$`.
|
|
1532
|
+
*/
|
|
1533
|
+
pipe(templates: TemplateStringsArray, ...expressions: readonly TemplateExpression[]):
|
|
1534
|
+
Promise<Result<{}>> & PipableSubprocess;
|
|
1535
|
+
pipe<OptionsType extends Options & PipeOptions = {}>(options: OptionsType):
|
|
1536
|
+
(templates: TemplateStringsArray, ...expressions: readonly TemplateExpression[])
|
|
1537
|
+
=> Promise<Result<OptionsType>> & PipableSubprocess;
|
|
375
1538
|
|
|
376
|
-
|
|
1539
|
+
/**
|
|
1540
|
+
Like `subprocess.pipe(file, arguments?, options?)` but using the return value of another `execa()` call instead.
|
|
1541
|
+
*/
|
|
1542
|
+
pipe<Destination extends ResultPromise>(destination: Destination, options?: PipeOptions):
|
|
1543
|
+
Promise<Awaited<Destination>> & PipableSubprocess;
|
|
1544
|
+
};
|
|
377
1545
|
|
|
378
|
-
|
|
1546
|
+
// `subprocess.readable|duplex|iterable()` options
|
|
1547
|
+
type ReadableOptions = {
|
|
1548
|
+
/**
|
|
1549
|
+
Which stream to read from the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.
|
|
1550
|
+
|
|
1551
|
+
`"all"` reads both `stdout` and `stderr`. This requires the `all` option to be `true`.
|
|
1552
|
+
|
|
1553
|
+
@default 'stdout'
|
|
1554
|
+
*/
|
|
1555
|
+
readonly from?: FromOption;
|
|
1556
|
+
|
|
1557
|
+
/**
|
|
1558
|
+
If `false`, iterates over lines. Each line is a string.
|
|
1559
|
+
|
|
1560
|
+
If `true`, iterates over arbitrary chunks of data. Each line is an [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) (with `subprocess.iterable()`) or a [`Buffer`](https://nodejs.org/api/buffer.html#class-buffer) (with `subprocess.readable()`/`subprocess.duplex()`).
|
|
1561
|
+
|
|
1562
|
+
This is always `true` when the `encoding` option is binary.
|
|
1563
|
+
|
|
1564
|
+
@default `false` with `subprocess.iterable()`, `true` otherwise
|
|
379
1565
|
*/
|
|
380
|
-
|
|
381
|
-
pipeStdout?(target: Writable | string): ExecaChildProcess<StdoutStderrType>;
|
|
1566
|
+
readonly binary?: boolean;
|
|
382
1567
|
|
|
383
1568
|
/**
|
|
384
|
-
|
|
1569
|
+
If both this option and the `binary` option is `false`, [newlines](https://en.wikipedia.org/wiki/Newline) are stripped from each line.
|
|
385
1570
|
|
|
386
|
-
|
|
1571
|
+
@default `false` with `subprocess.iterable()`, `true` otherwise
|
|
387
1572
|
*/
|
|
388
|
-
|
|
389
|
-
|
|
1573
|
+
readonly preserveNewlines?: boolean;
|
|
1574
|
+
};
|
|
390
1575
|
|
|
1576
|
+
// `subprocess.writable|duplex()` options
|
|
1577
|
+
type WritableOptions = {
|
|
391
1578
|
/**
|
|
392
|
-
|
|
1579
|
+
Which stream to write to the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.
|
|
393
1580
|
|
|
394
|
-
|
|
1581
|
+
@default 'stdin'
|
|
395
1582
|
*/
|
|
396
|
-
|
|
397
|
-
pipeAll?(target: Writable | string): ExecaChildProcess<StdoutStderrType>;
|
|
1583
|
+
readonly to?: ToOption;
|
|
398
1584
|
};
|
|
399
1585
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
1586
|
+
// `subprocess.duplex()` options
|
|
1587
|
+
type DuplexOptions = ReadableOptions & WritableOptions;
|
|
1588
|
+
|
|
1589
|
+
// `subprocess.iterable()` return value
|
|
1590
|
+
type SubprocessAsyncIterable<
|
|
1591
|
+
BinaryOption extends boolean | undefined,
|
|
1592
|
+
EncodingOption extends Options['encoding'],
|
|
1593
|
+
> = AsyncIterableIterator<
|
|
1594
|
+
EncodingOption extends BinaryEncodingOption
|
|
1595
|
+
? Uint8Array
|
|
1596
|
+
: BinaryOption extends true
|
|
1597
|
+
? Uint8Array
|
|
1598
|
+
: string
|
|
1599
|
+
>;
|
|
1600
|
+
|
|
1601
|
+
// `subprocess.stdin|stdout|stderr|stdio`
|
|
1602
|
+
type SubprocessStdioStream<
|
|
1603
|
+
FdNumber extends string,
|
|
1604
|
+
OptionsType extends Options,
|
|
1605
|
+
> = SubprocessStream<FdNumber, IgnoresSubprocessOutput<FdNumber, OptionsType>, OptionsType>;
|
|
1606
|
+
|
|
1607
|
+
type SubprocessStream<
|
|
1608
|
+
FdNumber extends string,
|
|
1609
|
+
StreamResultIgnored,
|
|
1610
|
+
OptionsType extends Options,
|
|
1611
|
+
> = StreamResultIgnored extends true
|
|
1612
|
+
? null
|
|
1613
|
+
: InputOutputStream<IsInputFd<FdNumber, OptionsType>>;
|
|
1614
|
+
|
|
1615
|
+
type InputOutputStream<IsInput extends boolean> = IsInput extends true
|
|
1616
|
+
? Writable
|
|
1617
|
+
: Readable;
|
|
1618
|
+
|
|
1619
|
+
// `subprocess.stdio`
|
|
1620
|
+
type SubprocessStdioArray<OptionsType extends Options> = MapStdioStreams<StdioOptionNormalizedArray<OptionsType>, OptionsType>;
|
|
1621
|
+
|
|
1622
|
+
// We cannot use mapped types because it must be compatible with Node.js `ChildProcess["stdio"]` which uses a tuple with exactly 5 items
|
|
1623
|
+
type MapStdioStreams<
|
|
1624
|
+
StdioOptionsArrayType,
|
|
1625
|
+
OptionsType extends Options,
|
|
1626
|
+
> = [
|
|
1627
|
+
SubprocessStdioStream<'0', OptionsType>,
|
|
1628
|
+
SubprocessStdioStream<'1', OptionsType>,
|
|
1629
|
+
SubprocessStdioStream<'2', OptionsType>,
|
|
1630
|
+
'3' extends keyof StdioOptionsArrayType ? SubprocessStdioStream<'3', OptionsType> : never,
|
|
1631
|
+
'4' extends keyof StdioOptionsArrayType ? SubprocessStdioStream<'4', OptionsType> : never,
|
|
1632
|
+
];
|
|
1633
|
+
|
|
1634
|
+
// `subprocess.all`
|
|
1635
|
+
type SubprocessAll<OptionsType extends Options> = AllStream<AllIgnored<OptionsType['all'], OptionsType>>;
|
|
1636
|
+
|
|
1637
|
+
type AllStream<IsIgnored> = IsIgnored extends true ? undefined : Readable;
|
|
1638
|
+
|
|
1639
|
+
type AllIgnored<
|
|
1640
|
+
AllOption,
|
|
1641
|
+
OptionsType extends Options,
|
|
1642
|
+
> = AllOption extends true
|
|
1643
|
+
? IgnoresSubprocessOutput<'1', OptionsType> extends true
|
|
1644
|
+
? IgnoresSubprocessOutput<'2', OptionsType>
|
|
1645
|
+
: false
|
|
1646
|
+
: true;
|
|
1647
|
+
|
|
1648
|
+
type ExecaCustomSubprocess<OptionsType extends Options> = {
|
|
1649
|
+
/**
|
|
1650
|
+
Process identifier ([PID](https://en.wikipedia.org/wiki/Process_identifier)).
|
|
1651
|
+
|
|
1652
|
+
This is `undefined` if the subprocess failed to spawn.
|
|
1653
|
+
*/
|
|
1654
|
+
pid?: number;
|
|
1655
|
+
|
|
1656
|
+
/**
|
|
1657
|
+
The subprocess [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)) as a stream.
|
|
1658
|
+
|
|
1659
|
+
This is `null` if the `stdin` option is set to `'inherit'`, `'ignore'`, `Readable` or `integer`.
|
|
1660
|
+
*/
|
|
1661
|
+
stdin: SubprocessStdioStream<'0', OptionsType>;
|
|
1662
|
+
|
|
1663
|
+
/**
|
|
1664
|
+
The subprocess [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) as a stream.
|
|
1665
|
+
|
|
1666
|
+
This is `null` if the `stdout` option is set to `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.
|
|
1667
|
+
*/
|
|
1668
|
+
stdout: SubprocessStdioStream<'1', OptionsType>;
|
|
1669
|
+
|
|
1670
|
+
/**
|
|
1671
|
+
The subprocess [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)) as a stream.
|
|
1672
|
+
|
|
1673
|
+
This is `null` if the `stderr` option is set to `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.
|
|
1674
|
+
*/
|
|
1675
|
+
stderr: SubprocessStdioStream<'2', OptionsType>;
|
|
1676
|
+
|
|
1677
|
+
/**
|
|
1678
|
+
Stream combining/interleaving `subprocess.stdout` and `subprocess.stderr`.
|
|
1679
|
+
|
|
1680
|
+
This requires the `all` option to be `true`.
|
|
1681
|
+
|
|
1682
|
+
This is `undefined` if `stdout` and `stderr` options are set to `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.
|
|
1683
|
+
*/
|
|
1684
|
+
all: SubprocessAll<OptionsType>;
|
|
1685
|
+
|
|
1686
|
+
/**
|
|
1687
|
+
The subprocess `stdin`, `stdout`, `stderr` and other files descriptors as an array of streams.
|
|
1688
|
+
|
|
1689
|
+
Each array item is `null` if the corresponding `stdin`, `stdout`, `stderr` or `stdio` option is set to `'inherit'`, `'ignore'`, `Stream` or `integer`, or if the `buffer` option is `false`.
|
|
1690
|
+
*/
|
|
1691
|
+
stdio: SubprocessStdioArray<OptionsType>;
|
|
1692
|
+
|
|
1693
|
+
/**
|
|
1694
|
+
Sends a [signal](https://nodejs.org/api/os.html#signal-constants) to the subprocess. The default signal is the `killSignal` option. `killSignal` defaults to `SIGTERM`, which terminates the subprocess.
|
|
1695
|
+
|
|
1696
|
+
This returns `false` when the signal could not be sent, for example when the subprocess has already exited.
|
|
1697
|
+
|
|
1698
|
+
When an error is passed as argument, it is set to the subprocess' `error.cause`. The subprocess is then terminated with the default signal. This does not emit the [`error` event](https://nodejs.org/api/child_process.html#event-error).
|
|
1699
|
+
|
|
1700
|
+
[More info.](https://nodejs.org/api/child_process.html#subprocesskillsignal)
|
|
1701
|
+
*/
|
|
1702
|
+
kill(signal?: keyof SignalConstants | number, error?: Error): boolean;
|
|
1703
|
+
kill(error?: Error): boolean;
|
|
1704
|
+
|
|
1705
|
+
/**
|
|
1706
|
+
Subprocesses are [async iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator). They iterate over each output line.
|
|
1707
|
+
*/
|
|
1708
|
+
[Symbol.asyncIterator](): SubprocessAsyncIterable<undefined, OptionsType['encoding']>;
|
|
1709
|
+
|
|
1710
|
+
/**
|
|
1711
|
+
Same as `subprocess[Symbol.asyncIterator]` except options can be provided.
|
|
1712
|
+
*/
|
|
1713
|
+
iterable<IterableOptions extends ReadableOptions = {}>(readableOptions?: IterableOptions): SubprocessAsyncIterable<IterableOptions['binary'], OptionsType['encoding']>;
|
|
1714
|
+
|
|
1715
|
+
/**
|
|
1716
|
+
Converts the subprocess to a readable stream.
|
|
1717
|
+
*/
|
|
1718
|
+
readable(readableOptions?: ReadableOptions): Readable;
|
|
1719
|
+
|
|
1720
|
+
/**
|
|
1721
|
+
Converts the subprocess to a writable stream.
|
|
1722
|
+
*/
|
|
1723
|
+
writable(writableOptions?: WritableOptions): Writable;
|
|
1724
|
+
|
|
1725
|
+
/**
|
|
1726
|
+
Converts the subprocess to a duplex stream.
|
|
1727
|
+
*/
|
|
1728
|
+
duplex(duplexOptions?: DuplexOptions): Duplex;
|
|
1729
|
+
}
|
|
1730
|
+
& IpcMethods<HasIpc<OptionsType>, OptionsType['serialization']>
|
|
1731
|
+
& PipableSubprocess;
|
|
1732
|
+
|
|
1733
|
+
/**
|
|
1734
|
+
[`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with additional methods and properties.
|
|
1735
|
+
*/
|
|
1736
|
+
type Subprocess<OptionsType extends Options = Options> =
|
|
1737
|
+
& Omit<ChildProcess, keyof ExecaCustomSubprocess<OptionsType>>
|
|
1738
|
+
& ExecaCustomSubprocess<OptionsType>;
|
|
1739
|
+
|
|
1740
|
+
/**
|
|
1741
|
+
The return value of all asynchronous methods is both:
|
|
1742
|
+
- the subprocess.
|
|
1743
|
+
- a `Promise` either resolving with its successful `result`, or rejecting with its `error`.
|
|
1744
|
+
*/
|
|
1745
|
+
type ResultPromise<OptionsType extends Options = Options> =
|
|
1746
|
+
& Subprocess<OptionsType>
|
|
1747
|
+
& Promise<Result<OptionsType>>;
|
|
403
1748
|
|
|
404
1749
|
declare const prompt: {
|
|
405
|
-
executeTask: (childProcessFactories: ((signal?: AbortSignal) =>
|
|
1750
|
+
executeTask: (childProcessFactories: ((signal?: AbortSignal) => ResultPromise) | ((signal?: AbortSignal) => ResultPromise)[], { intro, error, success, abortable, }: {
|
|
406
1751
|
intro: string;
|
|
407
1752
|
error: string;
|
|
408
1753
|
success: string;
|
|
409
1754
|
abortable?: boolean;
|
|
410
|
-
}) => Promise<void>;
|
|
411
|
-
executeTaskWithSpinner: (childProcessFactories: ((signal?: AbortSignal) =>
|
|
1755
|
+
}) => Promise<"aborted" | void>;
|
|
1756
|
+
executeTaskWithSpinner: (childProcessFactories: ((signal?: AbortSignal) => ResultPromise) | ((signal?: AbortSignal) => ResultPromise)[], { id, intro, error, success, abortable, }: {
|
|
412
1757
|
id: string;
|
|
413
1758
|
intro: string;
|
|
414
1759
|
error: string;
|
|
415
1760
|
success: string;
|
|
416
1761
|
abortable?: boolean;
|
|
417
|
-
}) => Promise<void>;
|
|
1762
|
+
}) => Promise<"aborted" | void>;
|
|
418
1763
|
setPromptLibrary: (library: "clack") => void;
|
|
419
1764
|
getPromptLibrary: () => "clack";
|
|
420
1765
|
getPromptProvider: () => PromptProvider;
|
|
@@ -677,4 +2022,4 @@ declare const once: {
|
|
|
677
2022
|
};
|
|
678
2023
|
declare const deprecate: (message: string) => void;
|
|
679
2024
|
|
|
680
|
-
export { CLI_COLORS, ConsoleLogger, type SpinnerInstance, StyledConsoleLogger, type TaskLogInstance, colors, createHyperlink, deprecate, npmlog as instance, logTracker, logger, once, prompt, protectUrls };
|
|
2025
|
+
export { CLI_COLORS, ConsoleLogger, type LogLevel, type SpinnerInstance, StyledConsoleLogger, type TaskLogInstance, colors, createHyperlink, deprecate, npmlog as instance, logTracker, logger, once, prompt, protectUrls };
|