@@ -56,6 +56,7 @@ import {
56
56
quote ,
57
57
quotePowerShell ,
58
58
toCamelCase ,
59
+ randomId ,
59
60
} from './util.js'
60
61
61
62
export { log , type LogEntry } from './util.js'
@@ -209,6 +210,7 @@ type PipeMethod = {
209
210
}
210
211
211
212
export class ProcessPromise extends Promise < ProcessOutput > {
213
+ private _id = randomId ( )
212
214
private _command = ''
213
215
private _from = ''
214
216
private _snapshot = getStore ( )
@@ -251,9 +253,8 @@ export class ProcessPromise extends Promise<ProcessOutput> {
251
253
this . _run = true
252
254
this . _pipedFrom ?.run ( )
253
255
254
- const $ = this . _snapshot
255
256
const self = this
256
- const input = ( $ . input as ProcessPromise | ProcessOutput ) ?. stdout ?? $ . input
257
+ const $ = this . _snapshot
257
258
258
259
if ( $ . timeout ) this . timeout ( $ . timeout , $ . timeoutSignal )
259
260
if ( $ . preferLocal ) {
@@ -268,22 +269,24 @@ export class ProcessPromise extends Promise<ProcessOutput> {
268
269
verbose : self . isVerbose ( ) ,
269
270
} )
270
271
272
+ // prettier-ignore
271
273
this . _zurk = exec ( {
272
- input,
273
- cmd : $ . prefix + self . _command + $ . postfix ,
274
- cwd : $ . cwd ?? $ [ CWD ] ,
275
- ac : $ . ac ,
276
- signal : $ . signal ,
277
- shell : isString ( $ . shell ) ? $ . shell : true ,
278
- env : $ . env ,
279
- spawn : $ . spawn ,
280
- spawnSync : $ . spawnSync ,
281
- store : $ . store ,
282
- stdin : self . _stdin ,
283
- stdio : self . _stdio ?? $ . stdio ,
284
- sync : $ [ SYNC ] ,
274
+ id : self . id ,
275
+ cmd : self . fullCmd ,
276
+ cwd : $ . cwd ?? $ [ CWD ] ,
277
+ input : ( $ . input as ProcessPromise | ProcessOutput ) ?. stdout ?? $ . input ,
278
+ ac : $ . ac ,
279
+ signal : $ . signal ,
280
+ shell : isString ( $ . shell ) ? $ . shell : true ,
281
+ env : $ . env ,
282
+ spawn : $ . spawn ,
283
+ spawnSync :$ . spawnSync ,
284
+ store : $ . store ,
285
+ stdin : self . _stdin ,
286
+ stdio : self . _stdio ?? $ . stdio ,
287
+ sync : $ [ SYNC ] ,
285
288
detached : $ . detached ,
286
- ee : self . _ee ,
289
+ ee : self . _ee ,
287
290
run : ( cb ) => cb ( ) ,
288
291
on : {
289
292
start : ( ) => {
@@ -298,13 +301,11 @@ export class ProcessPromise extends Promise<ProcessOutput> {
298
301
// Stderr should be printed regardless of piping.
299
302
$ . log ( { kind : 'stderr' , data, verbose : ! self . isQuiet ( ) } )
300
303
} ,
301
- // prettier-ignore
302
304
end : ( data , c ) => {
303
305
self . _resolved = true
304
306
const { error, status, signal, duration, ctx } = data
305
307
const { stdout, stderr, stdall } = ctx . store
306
308
const dto : ProcessOutputLazyDto = {
307
- // Lazy getters
308
309
code : ( ) => status ,
309
310
signal : ( ) => signal ,
310
311
duration : ( ) => duration ,
@@ -439,6 +440,10 @@ export class ProcessPromise extends Promise<ProcessOutput> {
439
440
}
440
441
441
442
// Getters
443
+ get id ( ) {
444
+ return this . _id
445
+ }
446
+
442
447
get pid ( ) : number | undefined {
443
448
return this . child ?. pid
444
449
}
@@ -447,6 +452,10 @@ export class ProcessPromise extends Promise<ProcessOutput> {
447
452
return this . _command
448
453
}
449
454
455
+ get fullCmd ( ) : string {
456
+ return this . _snapshot . prefix + this . cmd + this . _snapshot . postfix
457
+ }
458
+
450
459
get child ( ) : ChildProcess | undefined {
451
460
return this . _zurk ?. child
452
461
}
0 commit comments