@@ -133,24 +133,23 @@ function resolveBuiltGlobalCliBinary(casesDir: string): string {
133133 path . join ( repoRoot , 'target' ) ,
134134 ] ;
135135 const candidates = targetDirs . flatMap ( ( targetDir ) => {
136- const directCandidates = [
136+ const targetCandidates = [
137137 path . join ( targetDir , 'release' , binaryName ) ,
138138 path . join ( targetDir , 'debug' , binaryName ) ,
139139 ] ;
140140 if ( ! fs . existsSync ( targetDir ) ) {
141- return directCandidates ;
141+ return targetCandidates ;
142142 }
143143
144- return [
145- ...directCandidates ,
146- ...fs
147- . readdirSync ( targetDir , { withFileTypes : true } )
148- . filter ( ( entry ) => entry . isDirectory ( ) )
149- . flatMap ( ( entry ) => [
144+ for ( const entry of fs . readdirSync ( targetDir , { withFileTypes : true } ) ) {
145+ if ( entry . isDirectory ( ) ) {
146+ targetCandidates . push (
150147 path . join ( targetDir , entry . name , 'release' , binaryName ) ,
151148 path . join ( targetDir , entry . name , 'debug' , binaryName ) ,
152- ] ) ,
153- ] ;
149+ ) ;
150+ }
151+ }
152+ return targetCandidates ;
154153 } ) ;
155154 const binaryPath = candidates . find ( ( candidate ) => fs . existsSync ( candidate ) ) ;
156155 if ( ! binaryPath ) {
0 commit comments