@@ -62,6 +62,7 @@ class Walker {
62
62
queue : new queue_1 . Queue ( ( error , state ) => this . callbackInvoker ( state , error , callback ) ) ,
63
63
symlinks : new Map ( ) ,
64
64
visited : [ "" ] . slice ( 0 , 0 ) ,
65
+ controller : new AbortController ( ) ,
65
66
} ;
66
67
/*
67
68
* Perf: We conditionally change functions according to options. This gives a slight
@@ -77,14 +78,16 @@ class Walker {
77
78
this . walkDirectory = walkDirectory . build ( this . isSynchronous ) ;
78
79
}
79
80
start ( ) {
81
+ this . pushDirectory ( this . root , this . state . paths , this . state . options . filters ) ;
80
82
this . walkDirectory ( this . state , this . root , this . root , this . state . options . maxDepth , this . walk ) ;
81
83
return this . isSynchronous ? this . callbackInvoker ( this . state , null ) : null ;
82
84
}
83
85
walk = ( entries , directoryPath , depth ) => {
84
- const { paths, options : { filters, resolveSymlinks, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator, } , } = this . state ;
85
- if ( ( signal && signal . aborted ) || ( maxFiles && paths . length > maxFiles ) )
86
+ const { paths, options : { filters, resolveSymlinks, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator, } , controller, } = this . state ;
87
+ if ( controller . signal . aborted ||
88
+ ( signal && signal . aborted ) ||
89
+ ( maxFiles && paths . length > maxFiles ) )
86
90
return ;
87
- this . pushDirectory ( directoryPath , paths , filters ) ;
88
91
const files = this . getArray ( this . state . paths ) ;
89
92
for ( let i = 0 ; i < entries . length ; ++ i ) {
90
93
const entry = entries [ i ] ;
@@ -97,9 +100,10 @@ class Walker {
97
100
let path = joinPath . joinDirectoryPath ( entry . name , directoryPath , this . state . options . pathSeparator ) ;
98
101
if ( exclude && exclude ( entry . name , path ) )
99
102
continue ;
103
+ this . pushDirectory ( path , paths , filters ) ;
100
104
this . walkDirectory ( this . state , path , path , depth - 1 , this . walk ) ;
101
105
}
102
- else if ( entry . isSymbolicLink ( ) && this . resolveSymlink ) {
106
+ else if ( this . resolveSymlink && entry . isSymbolicLink ( ) ) {
103
107
let path = joinPath . joinPathWithBasePath ( entry . name , directoryPath ) ;
104
108
this . resolveSymlink ( path , this . state , ( stat , resolvedPath ) => {
105
109
if ( stat . isDirectory ( ) ) {
0 commit comments