1
- import { Buffer } from 'node:buffer' ;
2
- import { ChildProcess } from 'node:child_process' ;
3
- import { Stream , Readable as ReadableStream } from 'node:stream' ;
1
+ import { type Buffer } from 'node:buffer' ;
2
+ import { type ChildProcess } from 'node:child_process' ;
3
+ import { type Stream , type Readable as ReadableStream } from 'node:stream' ;
4
4
5
5
export type StdioOption =
6
6
| 'pipe'
@@ -12,7 +12,7 @@ export type StdioOption =
12
12
| number
13
13
| undefined ;
14
14
15
- export interface CommonOptions < EncodingType > {
15
+ export type CommonOptions < EncodingType > = {
16
16
/**
17
17
Kill the spawned process when the parent process exits unless either:
18
18
- the spawned process is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)
@@ -244,23 +244,23 @@ export interface CommonOptions<EncodingType> {
244
244
@default true
245
245
*/
246
246
readonly windowsHide ?: boolean ;
247
- }
247
+ } ;
248
248
249
- export interface Options < EncodingType = string > extends CommonOptions < EncodingType > {
249
+ export type Options < EncodingType = string > = {
250
250
/**
251
251
Write some input to the `stdin` of your binary.
252
252
*/
253
253
readonly input ?: string | Buffer | ReadableStream ;
254
- }
254
+ } & CommonOptions < EncodingType > ;
255
255
256
- export interface SyncOptions < EncodingType = string > extends CommonOptions < EncodingType > {
256
+ export type SyncOptions < EncodingType = string > = {
257
257
/**
258
258
Write some input to the `stdin` of your binary.
259
259
*/
260
260
readonly input ?: string | Buffer ;
261
- }
261
+ } & CommonOptions < EncodingType > ;
262
262
263
- export interface NodeOptions < EncodingType = string > extends Options < EncodingType > {
263
+ export type NodeOptions < EncodingType = string > = {
264
264
/**
265
265
The Node.js executable to use.
266
266
@@ -274,9 +274,9 @@ export interface NodeOptions<EncodingType = string> extends Options<EncodingType
274
274
@default process.execArgv
275
275
*/
276
276
readonly nodeOptions ?: string [ ] ;
277
- }
277
+ } & Options < EncodingType > ;
278
278
279
- export interface ExecaReturnBase < StdoutStderrType > {
279
+ export type ExecaReturnBase < StdoutStderrType > = {
280
280
/**
281
281
The file and arguments that were run, for logging purposes.
282
282
@@ -335,11 +335,10 @@ export interface ExecaReturnBase<StdoutStderrType> {
335
335
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.
336
336
*/
337
337
signalDescription ?: string ;
338
- }
338
+ } ;
339
339
340
- export interface ExecaSyncReturnValue < StdoutErrorType = string >
341
- extends ExecaReturnBase < StdoutErrorType > {
342
- }
340
+ export type ExecaSyncReturnValue < StdoutErrorType = string > = {
341
+ } & ExecaReturnBase < StdoutErrorType > ;
343
342
344
343
/**
345
344
Result of a child process execution. On success this is a plain object. On failure this is also an `Error` instance.
@@ -351,8 +350,7 @@ The child process fails when:
351
350
- being canceled
352
351
- there's not enough memory or there are already too many child processes
353
352
*/
354
- export interface ExecaReturnValue < StdoutErrorType = string >
355
- extends ExecaSyncReturnValue < StdoutErrorType > {
353
+ export type ExecaReturnValue < StdoutErrorType = string > = {
356
354
/**
357
355
The output of the process with `stdout` and `stderr` interleaved.
358
356
@@ -368,11 +366,9 @@ export interface ExecaReturnValue<StdoutErrorType = string>
368
366
You can cancel the spawned process using the [`signal`](https://github.com/sindresorhus/execa#signal-1) option.
369
367
*/
370
368
isCanceled : boolean ;
371
- }
369
+ } & ExecaSyncReturnValue < StdoutErrorType > ;
372
370
373
- export interface ExecaSyncError < StdoutErrorType = string >
374
- extends Error ,
375
- ExecaReturnBase < StdoutErrorType > {
371
+ export type ExecaSyncError < StdoutErrorType = string > = {
376
372
/**
377
373
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.
378
374
@@ -391,10 +387,9 @@ export interface ExecaSyncError<StdoutErrorType = string>
391
387
This is `undefined` unless the child process exited due to an `error` event or a timeout.
392
388
*/
393
389
originalMessage ?: string ;
394
- }
390
+ } & Error & ExecaReturnBase < StdoutErrorType > ;
395
391
396
- export interface ExecaError < StdoutErrorType = string >
397
- extends ExecaSyncError < StdoutErrorType > {
392
+ export type ExecaError < StdoutErrorType = string > = {
398
393
/**
399
394
The output of the process with `stdout` and `stderr` interleaved.
400
395
@@ -408,9 +403,9 @@ export interface ExecaError<StdoutErrorType = string>
408
403
Whether the process was canceled.
409
404
*/
410
405
isCanceled : boolean ;
411
- }
406
+ } & ExecaSyncError < StdoutErrorType > ;
412
407
413
- export interface KillOptions {
408
+ export type KillOptions = {
414
409
/**
415
410
Milliseconds to wait for the child process to terminate before sending `SIGKILL`.
416
411
@@ -419,9 +414,9 @@ export interface KillOptions {
419
414
@default 5000
420
415
*/
421
416
forceKillAfterTimeout ?: number | false ;
422
- }
417
+ } ;
423
418
424
- export interface ExecaChildPromise < StdoutErrorType > {
419
+ export type ExecaChildPromise < StdoutErrorType > = {
425
420
/**
426
421
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).
427
422
@@ -444,7 +439,7 @@ export interface ExecaChildPromise<StdoutErrorType> {
444
439
Similar to [`childProcess.kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal). This used to be preferred when cancelling the child process execution as the error is more descriptive and [`childProcessResult.isCanceled`](#iscanceled) is set to `true`. But now this is deprecated and you should either use `.kill()` or the `signal` option when creating the child process.
445
440
*/
446
441
cancel ( ) : void ;
447
- }
442
+ } ;
448
443
449
444
export type ExecaChildProcess < StdoutErrorType = string > = ChildProcess &
450
445
ExecaChildPromise < StdoutErrorType > &
0 commit comments