( 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 )
| 1944 | } |
| 1945 | |
| 1946 | export async function scanDirectoryAsync( |
| 1947 | rootDir: string, |
| 1948 | onProgress?: (current: number, file: string) => void, |
| 1949 | stats?: ScanSkipStats, |
| 1950 | /** Given what git's listings say about the package manifests (git repositories only; see ManifestEvidence). */ |
| 1951 | onManifestEvidence?: (evidence: ManifestEvidence) => void |
| 1952 | ): Promise<string[]> { |
| 1953 | // Custom extension → language overrides from the project's codegraph.json. |
| 1954 | const overrides = loadExtensionOverrides(rootDir); |
| 1955 | |
| 1956 | const gitFiles = getGitVisibleFiles(rootDir, onManifestEvidence); |
| 1957 | if (gitFiles) { |
| 1958 | const files: string[] = []; |
| 1959 | let count = 0; |
| 1960 | for (const filePath of gitFiles) { |
| 1961 | if (isSourceFile(filePath, overrides, rootDir)) { |
| 1962 | files.push(filePath); |
| 1963 | count++; |
| 1964 | onProgress?.(count, filePath); |
| 1965 | // Yield every 100 files so worker threads can render progress |
| 1966 | if (count % 100 === 0) { |
| 1967 | await new Promise<void>(r => setImmediate(r)); |
| 1968 | } |
| 1969 | } else { |
| 1970 | tallySkip(stats, filePath); |
| 1971 | } |
| 1972 | } |
| 1973 | return files; |
| 1974 | } |
| 1975 | |
| 1976 | return scanDirectoryWalk(rootDir, onProgress, stats); |
| 1977 | } |
| 1978 | |
| 1979 | /** |
| 1980 | * Filesystem walk fallback for non-git projects. |
no test coverage detected