(projectRoot: string)
| 1038 | * Remove the .codegraph directory |
| 1039 | */ |
| 1040 | export function removeDirectory(projectRoot: string): void { |
| 1041 | const codegraphDir = getCodeGraphDir(projectRoot); |
| 1042 | |
| 1043 | if (!fs.existsSync(codegraphDir)) { |
| 1044 | return; |
| 1045 | } |
| 1046 | |
| 1047 | // Verify .codegraph is a real directory, not a symlink pointing elsewhere |
| 1048 | const lstat = fs.lstatSync(codegraphDir); |
| 1049 | if (lstat.isSymbolicLink()) { |
| 1050 | // Only remove the symlink itself, never follow it for recursive delete |
| 1051 | fs.unlinkSync(codegraphDir); |
| 1052 | return; |
| 1053 | } |
| 1054 | |
| 1055 | if (!lstat.isDirectory()) { |
| 1056 | // Not a directory - remove the single file |
| 1057 | fs.unlinkSync(codegraphDir); |
| 1058 | return; |
| 1059 | } |
| 1060 | |
| 1061 | // Recursively remove directory |
| 1062 | fs.rmSync(codegraphDir, { recursive: true, force: true }); |
| 1063 | } |
| 1064 | |
| 1065 | /** |
| 1066 | * Get all files in the .codegraph directory |
no test coverage detected