@@ -405,30 +405,30 @@ export class GlobWalker<
405
405
406
406
async walk ( ) : Promise < Matches < O > > {
407
407
if ( this . signal ?. aborted ) throw this . signal . reason
408
- const t = this . path . isUnknown ( ) ? await this . path . lstat ( ) : this . path
409
- if ( t ) {
410
- await new Promise ( ( res , rej ) => {
411
- this . walkCB ( t , this . patterns , ( ) => {
412
- if ( this . signal ?. aborted ) {
413
- rej ( this . signal . reason )
414
- } else {
415
- res ( this . matches )
416
- }
417
- } )
418
- } )
408
+ if ( this . path . isUnknown ( ) ) {
409
+ await this . path . lstat ( )
419
410
}
411
+ await new Promise ( ( res , rej ) => {
412
+ this . walkCB ( this . path , this . patterns , ( ) => {
413
+ if ( this . signal ?. aborted ) {
414
+ rej ( this . signal . reason )
415
+ } else {
416
+ res ( this . matches )
417
+ }
418
+ } )
419
+ } )
420
420
return this . matches
421
421
}
422
422
423
423
walkSync ( ) : Matches < O > {
424
424
if ( this . signal ?. aborted ) throw this . signal . reason
425
- const t = this . path . isUnknown ( ) ? this . path . lstatSync ( ) : this . path
426
- // nothing for the callback to do, because this never pauses
427
- if ( t ) {
428
- this . walkCBSync ( t , this . patterns , ( ) => {
429
- if ( this . signal ?. aborted ) throw this . signal . reason
430
- } )
425
+ if ( this . path . isUnknown ( ) ) {
426
+ this . path . lstatSync ( )
431
427
}
428
+ // nothing for the callback to do, because this never pauses
429
+ this . walkCBSync ( this . path , this . patterns , ( ) => {
430
+ if ( this . signal ?. aborted ) throw this . signal . reason
431
+ } )
432
432
return this . matches
433
433
}
434
434
}
@@ -463,12 +463,8 @@ export class GlobStream<
463
463
stream ( ) : MatchStream < O > {
464
464
const target = this . path
465
465
if ( target . isUnknown ( ) ) {
466
- target . lstat ( ) . then ( e => {
467
- if ( e ) {
468
- this . walkCB ( target , this . patterns , ( ) => this . results . end ( ) )
469
- } else {
470
- this . results . end ( )
471
- }
466
+ target . lstat ( ) . then ( ( ) => {
467
+ this . walkCB ( target , this . patterns , ( ) => this . results . end ( ) )
472
468
} )
473
469
} else {
474
470
this . walkCB ( target , this . patterns , ( ) => this . results . end ( ) )
@@ -477,14 +473,10 @@ export class GlobStream<
477
473
}
478
474
479
475
streamSync ( ) : MatchStream < O > {
480
- const target = this . path . isUnknown ( )
481
- ? this . path . lstatSync ( )
482
- : this . path
483
- if ( target ) {
484
- this . walkCBSync ( target , this . patterns , ( ) => this . results . end ( ) )
485
- } else {
486
- this . results . end ( )
476
+ if ( this . path . isUnknown ( ) ) {
477
+ this . path . lstatSync ( )
487
478
}
479
+ this . walkCBSync ( this . path , this . patterns , ( ) => this . results . end ( ) )
488
480
return this . results
489
481
}
490
482
}
0 commit comments