MCPcopy Index your code
hub / github.com/forloopcodes/contextplus / walkRecursive

Function walkRecursive

src/core/walker.ts:51–74  ·  view source on GitHub ↗
(
  dir: string,
  rootDir: string,
  ig: Ignore,
  depth: number,
  maxDepth: number,
  results: FileEntry[],
)

Source from the content-addressed store, hash-verified

49}
50
51async function walkRecursive(
52 dir: string,
53 rootDir: string,
54 ig: Ignore,
55 depth: number,
56 maxDepth: number,
57 results: FileEntry[],
58): Promise<void> {
59 if (maxDepth > 0 && depth > maxDepth) return;
60
61 const entries = await readdir(dir, { withFileTypes: true }).catch(() => []);
62 for (const entry of entries) {
63 if (ALWAYS_IGNORE.has(entry.name) || entry.name.startsWith(".")) continue;
64
65 const fullPath = join(dir, entry.name);
66 const relPath = relative(rootDir, fullPath).replace(/\\/g, "/");
67 if (ig.ignores(relPath)) continue;
68
69 const isDir = entry.isDirectory();
70 results.push({ path: fullPath, relativePath: relPath, isDirectory: isDir, depth });
71
72 if (isDir) await walkRecursive(fullPath, rootDir, ig, depth + 1, maxDepth, results);
73 }
74}
75
76export async function walkDirectory(options: WalkOptions): Promise<FileEntry[]> {
77 const rootDir = resolve(options.rootDir);

Callers 1

walkDirectoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected