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

Function scanDirectoryAsync

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

Source from the content-addressed store, hash-verified

956 * allowing worker threads to receive and render progress messages.
957 */
958export async function scanDirectoryAsync(
959 rootDir: string,
960 onProgress?: (current: number, file: string) => void
961): Promise<string[]> {
962 // Custom extension → language overrides from the project's codegraph.json.
963 const overrides = loadExtensionOverrides(rootDir);
964
965 const gitFiles = getGitVisibleFiles(rootDir);
966 if (gitFiles) {
967 const files: string[] = [];
968 let count = 0;
969 for (const filePath of gitFiles) {
970 if (isSourceFile(filePath, overrides)) {
971 files.push(filePath);
972 count++;
973 onProgress?.(count, filePath);
974 // Yield every 100 files so worker threads can render progress
975 if (count % 100 === 0) {
976 await new Promise<void>(r => setImmediate(r));
977 }
978 }
979 }
980 return files;
981 }
982
983 return scanDirectoryWalk(rootDir, onProgress);
984}
985
986/**
987 * Filesystem walk fallback for non-git projects.

Callers 2

indexAllMethod · 0.85
syncMethod · 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