(projectRoot: string)
| 530 | * Get the total size of the .codegraph directory in bytes |
| 531 | */ |
| 532 | export function getDirectorySize(projectRoot: string): number { |
| 533 | const codegraphDir = getCodeGraphDir(projectRoot); |
| 534 | |
| 535 | if (!fs.existsSync(codegraphDir)) { |
| 536 | return 0; |
| 537 | } |
| 538 | |
| 539 | let totalSize = 0; |
| 540 | |
| 541 | function walkDir(dir: string): void { |
| 542 | const entries = fs.readdirSync(dir, { withFileTypes: true }); |
| 543 | |
| 544 | for (const entry of entries) { |
| 545 | // Skip symlinks to prevent following links outside .codegraph |
| 546 | if (entry.isSymbolicLink()) { |
| 547 | continue; |
| 548 | } |
| 549 | |
| 550 | const fullPath = path.join(dir, entry.name); |
| 551 | |
| 552 | if (entry.isDirectory()) { |
| 553 | walkDir(fullPath); |
| 554 | } else { |
| 555 | const stats = fs.statSync(fullPath); |
| 556 | totalSize += stats.size; |
| 557 | } |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | walkDir(codegraphDir); |
| 562 | return totalSize; |
| 563 | } |
| 564 | |
| 565 | /** |
| 566 | * Ensure a subdirectory exists within .codegraph |
nothing calls this directly
no test coverage detected