MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / removeDirectory

Function removeDirectory

src/directory.ts:1041–1064  ·  view source on GitHub ↗
(projectRoot: string)

Source from the content-addressed store, hash-verified

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

Callers 1

uninitializeMethod · 0.90

Calls 1

getCodeGraphDirFunction · 0.85

Tested by

no test coverage detected