MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / readDirectoryRecursive

Function readDirectoryRecursive

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

valuesMethod · 0.45
pushMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected