File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,8 @@ export interface Options {
59
59
ac ?: AbortController
60
60
signal ?: AbortSignal
61
61
input ?: string | Buffer | Readable | ProcessOutput | ProcessPromise
62
+ timeout ?: Duration
63
+ timeoutSignal ?: string
62
64
stdio : StdioOptions
63
65
verbose : boolean
64
66
sync : boolean
@@ -246,6 +248,7 @@ export class ProcessPromise extends Promise<ProcessOutput> {
246
248
const input = ( $ . input as ProcessPromise | ProcessOutput ) ?. stdout ?? $ . input
247
249
248
250
if ( input ) this . stdio ( 'pipe' )
251
+ if ( $ . timeout ) this . timeout ( $ . timeout , $ . timeoutSignal )
249
252
250
253
$ . log ( {
251
254
kind : 'cmd' ,
Original file line number Diff line number Diff line change @@ -480,6 +480,21 @@ describe('core', () => {
480
480
assert . equal ( signal , 'SIGKILL' )
481
481
} )
482
482
483
+ test ( 'timeout is configurable via opts' , async ( ) => {
484
+ let exitCode , signal
485
+ try {
486
+ await $ ( {
487
+ timeout : 10 ,
488
+ timeoutSignal : 'SIGKILL' ,
489
+ } ) `sleep 999`
490
+ } catch ( p ) {
491
+ exitCode = p . exitCode
492
+ signal = p . signal
493
+ }
494
+ assert . equal ( exitCode , null )
495
+ assert . equal ( signal , 'SIGKILL' )
496
+ } )
497
+
483
498
test ( 'timeout() expiration works' , async ( ) => {
484
499
let exitCode , signal
485
500
try {
You can’t perform that action at this time.
0 commit comments