MCPcopy Index your code
hub / github.com/CodeGraphContext/CodeGraphContext / readDirectoryRecursive

Function readDirectoryRecursive

website/src/lib/parser.ts:46–61  ·  view source on GitHub ↗
(dirHandle: any, prefix = "")

Source from the content-addressed store, hash-verified

44
45// UPLOADER UTILITIES
46export async function readDirectoryRecursive(dirHandle: any, prefix = "") {
47 let files: { path: string, content: string }[] = [];
48 for await (const entry of dirHandle.values()) {
49 if (entry.kind === 'file') {
50 if (entry.name.match(/\.(js|ts|jsx|tsx|py|c|h|cpp|hpp|cc|cs|go|rs|rb|php|swift|kt|kts|dart)$/)) {
51 const file = await entry.getFile();
52 files.push({ path: `${prefix}/${entry.name}`, content: await file.text() });
53 }
54 } else if (entry.kind === 'directory') {
55 if (!['node_modules', '.git', 'dist', 'build', '.idea', '__pycache__'].includes(entry.name)) {
56 files = files.concat(await readDirectoryRecursive(entry, `${prefix}/${entry.name}`));
57 }
58 }
59 }
60 return files;
61}
62
63export async function unzipFiles(zipBuffer: ArrayBuffer) {
64 const jszip = await JSZip.loadAsync(zipBuffer);

Callers

nothing calls this directly

Calls 3

valuesMethod · 0.80
pushMethod · 0.80
textMethod · 0.45

Tested by

no test coverage detected