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

Function scanDirectoryAsync

src/extraction/index.ts:1909–1940  ·  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

1907}
1908
1909export 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.

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