(projectRoot: string)
| 1101 | * Get the total size of the .codegraph directory in bytes |
| 1102 | */ |
| 1103 | export function getDirectorySize(projectRoot: string): number { |
| 1104 | const codegraphDir = getCodeGraphDir(projectRoot); |
| 1105 | |
| 1106 | if (!fs.existsSync(codegraphDir)) { |
| 1107 | return 0; |
| 1108 | } |
| 1109 | |
| 1110 | let totalSize = 0; |
| 1111 | |
| 1112 | function walkDir(dir: string): void { |
| 1113 | const entries = fs.readdirSync(dir, { withFileTypes: true }); |
| 1114 | |
| 1115 | for (const entry of entries) { |
| 1116 | // Skip symlinks to prevent following links outside .codegraph |
| 1117 | if (entry.isSymbolicLink()) { |
| 1118 | continue; |
| 1119 | } |
| 1120 | |
| 1121 | const fullPath = path.join(dir, entry.name); |
| 1122 | |
| 1123 | if (entry.isDirectory()) { |
| 1124 | walkDir(fullPath); |
| 1125 | } else { |
| 1126 | const stats = fs.statSync(fullPath); |
| 1127 | totalSize += stats.size; |
| 1128 | } |
| 1129 | } |
| 1130 | } |
| 1131 | |
| 1132 | walkDir(codegraphDir); |
| 1133 | return totalSize; |
| 1134 | } |
| 1135 | |
| 1136 | /** |
| 1137 | * Ensure a subdirectory exists within .codegraph |
nothing calls this directly
no test coverage detected