( rootDir: string, onProgress?: (current: number, file: string) => void )
| 956 | * allowing worker threads to receive and render progress messages. |
| 957 | */ |
| 958 | export async function scanDirectoryAsync( |
| 959 | rootDir: string, |
| 960 | onProgress?: (current: number, file: string) => void |
| 961 | ): Promise<string[]> { |
| 962 | // Custom extension → language overrides from the project's codegraph.json. |
| 963 | const overrides = loadExtensionOverrides(rootDir); |
| 964 | |
| 965 | const gitFiles = getGitVisibleFiles(rootDir); |
| 966 | if (gitFiles) { |
| 967 | const files: string[] = []; |
| 968 | let count = 0; |
| 969 | for (const filePath of gitFiles) { |
| 970 | if (isSourceFile(filePath, overrides)) { |
| 971 | files.push(filePath); |
| 972 | count++; |
| 973 | onProgress?.(count, filePath); |
| 974 | // Yield every 100 files so worker threads can render progress |
| 975 | if (count % 100 === 0) { |
| 976 | await new Promise<void>(r => setImmediate(r)); |
| 977 | } |
| 978 | } |
| 979 | } |
| 980 | return files; |
| 981 | } |
| 982 | |
| 983 | return scanDirectoryWalk(rootDir, onProgress); |
| 984 | } |
| 985 | |
| 986 | /** |
| 987 | * Filesystem walk fallback for non-git projects. |
no test coverage detected