@@ -62,6 +62,7 @@ class Walker {
6262 queue : new queue_1 . Queue ( ( error , state ) => this . callbackInvoker ( state , error , callback ) ) ,
6363 symlinks : new Map ( ) ,
6464 visited : [ "" ] . slice ( 0 , 0 ) ,
65+ controller : new AbortController ( ) ,
6566 } ;
6667 /*
6768 * Perf: We conditionally change functions according to options. This gives a slight
@@ -77,14 +78,16 @@ class Walker {
7778 this . walkDirectory = walkDirectory . build ( this . isSynchronous ) ;
7879 }
7980 start ( ) {
81+ this . pushDirectory ( this . root , this . state . paths , this . state . options . filters ) ;
8082 this . walkDirectory ( this . state , this . root , this . root , this . state . options . maxDepth , this . walk ) ;
8183 return this . isSynchronous ? this . callbackInvoker ( this . state , null ) : null ;
8284 }
8385 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 ) )
8690 return ;
87- this . pushDirectory ( directoryPath , paths , filters ) ;
8891 const files = this . getArray ( this . state . paths ) ;
8992 for ( let i = 0 ; i < entries . length ; ++ i ) {
9093 const entry = entries [ i ] ;
@@ -97,9 +100,10 @@ class Walker {
97100 let path = joinPath . joinDirectoryPath ( entry . name , directoryPath , this . state . options . pathSeparator ) ;
98101 if ( exclude && exclude ( entry . name , path ) )
99102 continue ;
103+ this . pushDirectory ( path , paths , filters ) ;
100104 this . walkDirectory ( this . state , path , path , depth - 1 , this . walk ) ;
101105 }
102- else if ( entry . isSymbolicLink ( ) && this . resolveSymlink ) {
106+ else if ( this . resolveSymlink && entry . isSymbolicLink ( ) ) {
103107 let path = joinPath . joinPathWithBasePath ( entry . name , directoryPath ) ;
104108 this . resolveSymlink ( path , this . state , ( stat , resolvedPath ) => {
105109 if ( stat . isDirectory ( ) ) {
0 commit comments