MCPcopy Create free account
hub / github.com/deepnote/deepnote / readDirRecursive

Function readDirRecursive

packages/cli/src/commands/install-skills.ts:267–284  ·  view source on GitHub ↗

Recursively reads all files in a directory, returning a map of relative paths to contents.

(baseDir: string, prefix = '')

Source from the content-addressed store, hash-verified

265
266/** Recursively reads all files in a directory, returning a map of relative paths to contents. */
267async function readDirRecursive(baseDir: string, prefix = ''): Promise<Map<string, string>> {
268 const contents = new Map<string, string>()
269 const entries = await fs.readdir(path.join(baseDir, prefix), { withFileTypes: true })
270
271 for (const entry of entries) {
272 const relativePath = path.join(prefix, entry.name)
273 if (entry.isDirectory()) {
274 const sub = await readDirRecursive(baseDir, relativePath)
275 for (const [key, value] of sub) {
276 contents.set(key, value)
277 }
278 } else {
279 contents.set(relativePath, await fs.readFile(path.join(baseDir, relativePath), 'utf8'))
280 }
281 }
282
283 return contents
284}
285
286async function detectAgents(baseDir: string, isGlobal: boolean, agentFilter?: string): Promise<AgentConfig[]> {
287 if (agentFilter) {

Callers 1

installSkillsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected