(projectRoot: string)
| 663 | * Remove the .codegraph directory |
| 664 | */ |
| 665 | export function removeDirectory(projectRoot: string): void { |
| 666 | const codegraphDir = getCodeGraphDir(projectRoot); |
| 667 | |
| 668 | if (!fs.existsSync(codegraphDir)) { |
| 669 | return; |
| 670 | } |
| 671 | |
| 672 | // Verify .codegraph is a real directory, not a symlink pointing elsewhere |
| 673 | const lstat = fs.lstatSync(codegraphDir); |
| 674 | if (lstat.isSymbolicLink()) { |
| 675 | // Only remove the symlink itself, never follow it for recursive delete |
| 676 | fs.unlinkSync(codegraphDir); |
| 677 | return; |
| 678 | } |
| 679 | |
| 680 | if (!lstat.isDirectory()) { |
| 681 | // Not a directory - remove the single file |
| 682 | fs.unlinkSync(codegraphDir); |
| 683 | return; |
| 684 | } |
| 685 | |
| 686 | // Recursively remove directory |
| 687 | fs.rmSync(codegraphDir, { recursive: true, force: true }); |
| 688 | } |
| 689 | |
| 690 | /** |
| 691 | * Get all files in the .codegraph directory |
no test coverage detected