(projectRoot: string)
| 722 | * Remove the .codegraph directory |
| 723 | */ |
| 724 | export function removeDirectory(projectRoot: string): void { |
| 725 | const codegraphDir = getCodeGraphDir(projectRoot); |
| 726 | |
| 727 | if (!fs.existsSync(codegraphDir)) { |
| 728 | return; |
| 729 | } |
| 730 | |
| 731 | // Verify .codegraph is a real directory, not a symlink pointing elsewhere |
| 732 | const lstat = fs.lstatSync(codegraphDir); |
| 733 | if (lstat.isSymbolicLink()) { |
| 734 | // Only remove the symlink itself, never follow it for recursive delete |
| 735 | fs.unlinkSync(codegraphDir); |
| 736 | return; |
| 737 | } |
| 738 | |
| 739 | if (!lstat.isDirectory()) { |
| 740 | // Not a directory - remove the single file |
| 741 | fs.unlinkSync(codegraphDir); |
| 742 | return; |
| 743 | } |
| 744 | |
| 745 | // Recursively remove directory |
| 746 | fs.rmSync(codegraphDir, { recursive: true, force: true }); |
| 747 | } |
| 748 | |
| 749 | /** |
| 750 | * Get all files in the .codegraph directory |
no test coverage detected