MCPcopy Create free account
hub / github.com/arctic-cli/interface / getDirectorySize

Function getDirectorySize

packages/arctic/src/cli/cmd/uninstall.ts:324–345  ·  view source on GitHub ↗
(dir: string)

Source from the content-addressed store, hash-verified

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

Callers 1

showRemovalSummaryFunction · 0.85

Calls 1

walkFunction · 0.70

Tested by

no test coverage detected