MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / scanDirectoryAsync

Function scanDirectoryAsync

src/extraction/index.ts:1946–1977  ·  view source on GitHub ↗
(
  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
)

Source from the content-addressed store, hash-verified

1944}
1945
1946export 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.

Callers 6

extraction.test.tsFile · 0.90
indexAllMethod · 0.85
syncMethod · 0.85

Calls 7

loadExtensionOverridesFunction · 0.90
isSourceFileFunction · 0.90
getGitVisibleFilesFunction · 0.85
onProgressFunction · 0.85
tallySkipFunction · 0.85
scanDirectoryWalkFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected