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

Function scanDirectoryAsync

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

Source from the content-addressed store, hash-verified

1215 * allowing worker threads to receive and render progress messages.
1216 */
1217export async function scanDirectoryAsync(
1218 rootDir: string,
1219 onProgress?: (current: number, file: string) => void
1220): Promise<string[]> {
1221 // Custom extension → language overrides from the project's codegraph.json.
1222 const overrides = loadExtensionOverrides(rootDir);
1223
1224 const gitFiles = getGitVisibleFiles(rootDir);
1225 if (gitFiles) {
1226 const files: string[] = [];
1227 let count = 0;
1228 for (const filePath of gitFiles) {
1229 if (isSourceFile(filePath, overrides)) {
1230 files.push(filePath);
1231 count++;
1232 onProgress?.(count, filePath);
1233 // Yield every 100 files so worker threads can render progress
1234 if (count % 100 === 0) {
1235 await new Promise<void>(r => setImmediate(r));
1236 }
1237 }
1238 }
1239 return files;
1240 }
1241
1242 return scanDirectoryWalk(rootDir, onProgress);
1243}
1244
1245/**
1246 * 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