( rootDir: string, onProgress?: (current: number, file: string) => void )
| 1215 | * allowing worker threads to receive and render progress messages. |
| 1216 | */ |
| 1217 | export async function scanDirectoryAsync( |
| 1218 | rootDir: string, |
| 1219 | onProgress?: (current: number, file: string) => void |
| 1220 | ): Promise<string[]> { |
| 1221 | // Custom extension → language overrides from the project's codegraph.json. |
| 1222 | const overrides = loadExtensionOverrides(rootDir); |
| 1223 | |
| 1224 | const gitFiles = getGitVisibleFiles(rootDir); |
| 1225 | if (gitFiles) { |
| 1226 | const files: string[] = []; |
| 1227 | let count = 0; |
| 1228 | for (const filePath of gitFiles) { |
| 1229 | if (isSourceFile(filePath, overrides)) { |
| 1230 | files.push(filePath); |
| 1231 | count++; |
| 1232 | onProgress?.(count, filePath); |
| 1233 | // Yield every 100 files so worker threads can render progress |
| 1234 | if (count % 100 === 0) { |
| 1235 | await new Promise<void>(r => setImmediate(r)); |
| 1236 | } |
| 1237 | } |
| 1238 | } |
| 1239 | return files; |
| 1240 | } |
| 1241 | |
| 1242 | return scanDirectoryWalk(rootDir, onProgress); |
| 1243 | } |
| 1244 | |
| 1245 | /** |
| 1246 | * Filesystem walk fallback for non-git projects. |
no test coverage detected