MCPcopy Create free account
hub / github.com/anomalyco/opencode / getDirectorySize

Function getDirectorySize

packages/opencode/src/cli/cmd/uninstall.ts:317–338  ·  view source on GitHub ↗
(dir: string)

Source from the content-addressed store, hash-verified

315}
316
317async function getDirectorySize(dir: string): Promise<number> {
318 let total = 0
319
320 const walk = async (current: string) => {
321 const entries = await fs.readdir(current, { withFileTypes: true }).catch(() => [])
322
323 for (const entry of entries) {
324 const full = path.join(current, entry.name)
325 if (entry.isDirectory()) {
326 await walk(full)
327 continue
328 }
329 if (entry.isFile()) {
330 const stat = await fs.stat(full).catch(() => null)
331 if (stat) total += stat.size
332 }
333 }
334 }
335
336 await walk(dir)
337 return total
338}
339
340function formatSize(bytes: number): string {
341 if (bytes < 1024) return `${bytes} B`

Callers 1

showRemovalSummaryFunction · 0.85

Calls 1

walkFunction · 0.70

Tested by

no test coverage detected