@@ -439,27 +439,23 @@ const VFS = {
439
439
440
440
var list = [ ] ;
441
441
442
+ function addIter ( file , stat ) {
443
+ const filename = _path . basename ( file ) . toLowerCase ( ) ;
444
+ const fpath = resolved . path + file . substr ( resolved . real . length ) . replace ( / ^ \/ / , '' ) ;
445
+ if ( filename . indexOf ( query ) !== - 1 ) {
446
+ const qpath = resolved . query + fpath . replace ( / ^ \/ / , '' ) ;
447
+ list . push ( createFileIter ( qpath , resolved . real , null , stat ) ) ;
448
+ }
449
+ }
450
+
442
451
find . on ( 'path' , function ( ) {
443
452
if ( qargs . limit && list . length >= qargs . limit ) {
444
453
find . stop ( ) ;
445
454
}
446
455
} ) ;
447
456
448
- find . on ( 'directory' , function ( dir , stat ) {
449
- const filename = _path . basename ( dir ) . toLowerCase ( ) ;
450
- const fpath = resolved . path + dir . substr ( resolved . real . length ) . replace ( / ^ \/ / , '' ) ;
451
- if ( filename . indexOf ( query ) !== - 1 ) {
452
- list . push ( createFileIter ( fpath , resolved . real , null , stat ) ) ;
453
- }
454
- } ) ;
455
-
456
- find . on ( 'file' , function ( file , stat ) {
457
- const filename = _path . basename ( file ) . toLowerCase ( ) ;
458
- const fpath = resolved . path + file . substr ( resolved . real . length ) . replace ( / ^ \/ / , '' ) ;
459
- if ( filename . indexOf ( query ) !== - 1 ) {
460
- list . push ( createFileIter ( fpath , resolved . real , null , stat ) ) ;
461
- }
462
- } ) ;
457
+ find . on ( 'directory' , addIter ) ;
458
+ find . on ( 'file' , addIter ) ;
463
459
464
460
find . on ( 'end' , function ( ) {
465
461
resolve ( list ) ;
0 commit comments