MCPcopy Index your code
hub / github.com/colbymchenry/codegraph / removeDirectory

Function removeDirectory

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

Source from the content-addressed store, hash-verified

467 * Remove the .codegraph directory
468 */
469export 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

Callers 1

uninitializeMethod · 0.90

Calls 1

getCodeGraphDirFunction · 0.85

Tested by

no test coverage detected