(projectRoot: string)
| 467 | * Remove the .codegraph directory |
| 468 | */ |
| 469 | export function removeDirectory(projectRoot: string): void { |
| 470 | const codegraphDir = getCodeGraphDir(projectRoot); |
| 471 | |
| 472 | if (!fs.existsSync(codegraphDir)) { |
| 473 | return; |
| 474 | } |
| 475 | |
| 476 | // Verify .codegraph is a real directory, not a symlink pointing elsewhere |
| 477 | const lstat = fs.lstatSync(codegraphDir); |
| 478 | if (lstat.isSymbolicLink()) { |
| 479 | // Only remove the symlink itself, never follow it for recursive delete |
| 480 | fs.unlinkSync(codegraphDir); |
| 481 | return; |
| 482 | } |
| 483 | |
| 484 | if (!lstat.isDirectory()) { |
| 485 | // Not a directory - remove the single file |
| 486 | fs.unlinkSync(codegraphDir); |
| 487 | return; |
| 488 | } |
| 489 | |
| 490 | // Recursively remove directory |
| 491 | fs.rmSync(codegraphDir, { recursive: true, force: true }); |
| 492 | } |
| 493 | |
| 494 | /** |
| 495 | * Get all files in the .codegraph directory |
no test coverage detected