( rootDir: string, onProgress?: (current: number, file: string) => void )
| 926 | * projects, falls back to a filesystem walk that parses .gitignore itself. |
| 927 | */ |
| 928 | export function scanDirectory( |
| 929 | rootDir: string, |
| 930 | onProgress?: (current: number, file: string) => void |
| 931 | ): string[] { |
| 932 | // Custom extension → language overrides from the project's codegraph.json. |
| 933 | const overrides = loadExtensionOverrides(rootDir); |
| 934 | |
| 935 | // Fast path: use git to get all visible files (respects .gitignore everywhere) |
| 936 | const gitFiles = getGitVisibleFiles(rootDir); |
| 937 | if (gitFiles) { |
| 938 | const files: string[] = []; |
| 939 | let count = 0; |
| 940 | for (const filePath of gitFiles) { |
| 941 | if (isSourceFile(filePath, overrides)) { |
| 942 | files.push(filePath); |
| 943 | count++; |
| 944 | onProgress?.(count, filePath); |
| 945 | } |
| 946 | } |
| 947 | return files; |
| 948 | } |
| 949 | |
| 950 | // Fallback: walk filesystem for non-git projects |
| 951 | return scanDirectoryWalk(rootDir, onProgress); |
| 952 | } |
| 953 | |
| 954 | /** |
| 955 | * Async variant of scanDirectory that yields to the event loop periodically, |
no test coverage detected