@@ -16,8 +16,13 @@ import {
16
16
17
17
import { DetectionConfig } from "../percy-snapshot-utils/types.js" ;
18
18
19
- async function walkDir ( dir : string , extensions : string [ ] ) : Promise < string [ ] > {
19
+ async function walkDir (
20
+ dir : string ,
21
+ extensions : string [ ] ,
22
+ depth : number = 6 ,
23
+ ) : Promise < string [ ] > {
20
24
const result : string [ ] = [ ] ;
25
+ if ( depth < 0 ) return result ;
21
26
try {
22
27
const entries = await fs . promises . readdir ( dir , { withFileTypes : true } ) ;
23
28
@@ -26,7 +31,7 @@ async function walkDir(dir: string, extensions: string[]): Promise<string[]> {
26
31
27
32
if ( entry . isDirectory ( ) ) {
28
33
if ( ! EXCLUDED_DIRS . has ( entry . name ) && ! entry . name . startsWith ( "." ) ) {
29
- result . push ( ...( await walkDir ( fullPath , extensions ) ) ) ;
34
+ result . push ( ...( await walkDir ( fullPath , extensions , depth - 1 ) ) ) ;
30
35
}
31
36
} else if ( extensions . some ( ( ext ) => entry . name . endsWith ( ext ) ) ) {
32
37
result . push ( fullPath ) ;
@@ -112,7 +117,7 @@ export async function listTestFiles(
112
117
// Step 1: Collect all files with matching extensions
113
118
let files : string [ ] = [ ] ;
114
119
try {
115
- files = await walkDir ( baseDir , config . extensions ) ;
120
+ files = await walkDir ( baseDir , config . extensions , 6 ) ;
116
121
} catch {
117
122
return [ ] ;
118
123
}
@@ -151,7 +156,7 @@ export async function listTestFiles(
151
156
// Step 4: Handle SpecFlow .feature files for C# + SpecFlow
152
157
if ( language === "csharp" && framework === "specflow" ) {
153
158
try {
154
- const featureFiles = await walkDir ( baseDir , [ ".feature" ] ) ;
159
+ const featureFiles = await walkDir ( baseDir , [ ".feature" ] , 6 ) ;
155
160
featureFiles . forEach ( ( file ) => candidateFiles . set ( file , 2 ) ) ;
156
161
logger . info ( `Added ${ featureFiles . length } SpecFlow .feature files` ) ;
157
162
} catch {
0 commit comments