MCPcopy
hub / github.com/colbymchenry/codegraph / scanDirectory

Function scanDirectory

src/extraction/index.ts:928–952  ·  view source on GitHub ↗
(
  rootDir: string,
  onProgress?: (current: number, file: string) => void
)

Source from the content-addressed store, hash-verified

926 * projects, falls back to a filesystem walk that parses .gitignore itself.
927 */
928export 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,

Callers 6

security.test.tsFile · 0.90
extraction.test.tsFile · 0.90
getChangedFilesMethod · 0.85

Calls 5

loadExtensionOverridesFunction · 0.90
isSourceFileFunction · 0.90
getGitVisibleFilesFunction · 0.85
onProgressFunction · 0.85
scanDirectoryWalkFunction · 0.85

Tested by

no test coverage detected