@@ -255,8 +255,10 @@ export class ProcessPromise extends Promise<ProcessOutput> {
255
255
256
256
const self = this
257
257
const $ = this . _snapshot
258
+ const sync = $ [ SYNC ]
259
+ const timeout = self . _timeout ?? $ . timeout
260
+ const timeoutSignal = self . _timeoutSignal ?? $ . timeoutSignal
258
261
259
- if ( $ . timeout ) this . timeout ( $ . timeout , $ . timeoutSignal )
260
262
if ( $ . preferLocal ) {
261
263
const dirs =
262
264
$ . preferLocal === true ? [ $ . cwd , $ [ CWD ] ] : [ $ . preferLocal ] . flat ( )
@@ -265,12 +267,13 @@ export class ProcessPromise extends Promise<ProcessOutput> {
265
267
266
268
$ . log ( {
267
269
kind : 'cmd' ,
268
- cmd : this . _command ,
270
+ cmd : self . cmd ,
269
271
verbose : self . isVerbose ( ) ,
270
272
} )
271
273
272
274
// prettier-ignore
273
275
this . _zurk = exec ( {
276
+ sync,
274
277
id : self . id ,
275
278
cmd : self . fullCmd ,
276
279
cwd : $ . cwd ?? $ [ CWD ] ,
@@ -284,13 +287,12 @@ export class ProcessPromise extends Promise<ProcessOutput> {
284
287
store : $ . store ,
285
288
stdin : self . _stdin ,
286
289
stdio : self . _stdio ?? $ . stdio ,
287
- sync : $ [ SYNC ] ,
288
290
detached : $ . detached ,
289
291
ee : self . _ee ,
290
292
run : ( cb ) => cb ( ) ,
291
293
on : {
292
294
start : ( ) => {
293
- self . _timeout && self . timeout ( self . _timeout , self . _timeoutSignal )
295
+ ! sync && timeout && self . timeout ( timeout , timeoutSignal )
294
296
} ,
295
297
stdout : ( data ) => {
296
298
// If process is piped, don't print output.
@@ -360,7 +362,7 @@ export class ProcessPromise extends Promise<ProcessOutput> {
360
362
} } )
361
363
}
362
364
private _pipe (
363
- source : 'stdout' | 'stderr' ,
365
+ source : keyof TSpawnStore ,
364
366
dest : PipeDest ,
365
367
...args : any [ ]
366
368
) : ( Writable & PromiseLike < ProcessPromise & Writable > ) | ProcessPromise {
@@ -513,11 +515,13 @@ export class ProcessPromise extends Promise<ProcessOutput> {
513
515
}
514
516
515
517
timeout ( d : Duration , signal = $ . timeoutSignal ) : ProcessPromise {
518
+ if ( this . _resolved ) return this
519
+
516
520
this . _timeout = parseDuration ( d )
517
521
this . _timeoutSignal = signal
518
522
519
523
if ( this . _timeoutId ) clearTimeout ( this . _timeoutId )
520
- if ( this . _timeout ) {
524
+ if ( this . _timeout && this . _run ) {
521
525
this . _timeoutId = setTimeout (
522
526
( ) => this . kill ( this . _timeoutSignal ) ,
523
527
this . _timeout
0 commit comments