( rootDir: string, onProgress?: (current: number, file: string) => void, stats?: ScanSkipStats, /** Given what git's listings say about the package manifests (git repositories only; see ManifestEvidence). */ onManifestEvidence?: (evidence: ManifestEvidence) => void )
| 1907 | } |
| 1908 | |
| 1909 | export async function scanDirectoryAsync( |
| 1910 | rootDir: string, |
| 1911 | onProgress?: (current: number, file: string) => void, |
| 1912 | stats?: ScanSkipStats, |
| 1913 | /** Given what git's listings say about the package manifests (git repositories only; see ManifestEvidence). */ |
| 1914 | onManifestEvidence?: (evidence: ManifestEvidence) => void |
| 1915 | ): Promise<string[]> { |
| 1916 | // Custom extension → language overrides from the project's codegraph.json. |
| 1917 | const overrides = loadExtensionOverrides(rootDir); |
| 1918 | |
| 1919 | const gitFiles = getGitVisibleFiles(rootDir, onManifestEvidence); |
| 1920 | if (gitFiles) { |
| 1921 | const files: string[] = []; |
| 1922 | let count = 0; |
| 1923 | for (const filePath of gitFiles) { |
| 1924 | if (isSourceFile(filePath, overrides, rootDir)) { |
| 1925 | files.push(filePath); |
| 1926 | count++; |
| 1927 | onProgress?.(count, filePath); |
| 1928 | // Yield every 100 files so worker threads can render progress |
| 1929 | if (count % 100 === 0) { |
| 1930 | await new Promise<void>(r => setImmediate(r)); |
| 1931 | } |
| 1932 | } else { |
| 1933 | tallySkip(stats, filePath); |
| 1934 | } |
| 1935 | } |
| 1936 | return files; |
| 1937 | } |
| 1938 | |
| 1939 | return scanDirectoryWalk(rootDir, onProgress, stats); |
| 1940 | } |
| 1941 | |
| 1942 | /** |
| 1943 | * Filesystem walk fallback for non-git projects. |
no test coverage detected