MCPcopy Create free account
hub / github.com/cli/cli / visit

Function visit

evals/src/core/sandbox.ts:125–143  ·  view source on GitHub ↗
(directory: string, depth: number)

Source from the content-addressed store, hash-verified

123 // the tree rather than assume a depth. The cap stops a mistaken root from walking a whole disk.
124 const found: string[] = [];
125 const visit = async (directory: string, depth: number): Promise<void> => {
126 let entries: Dirent[];
127 try { entries = await readdir(directory, { withFileTypes: true }); }
128 catch (error) {
129 if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) return;
130 throw error;
131 }
132 for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
133 const path = join(directory, entry.name);
134 if (entry.isDirectory() && depth < 10) await visit(path, depth + 1);
135 else if (entry.isFile() && entry.name === "resources.json") {
136 try {
137 if (!(await parseJournalFile(path)).cleaned) found.push(path);
138 } catch {
139 found.push(path);
140 }
141 }
142 }
143 };
144 await visit(root, 0);
145 return found;
146}

Callers 1

unfinishedJournalsFunction · 0.85

Calls 2

parseJournalFileFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected