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

Function removeDirectory

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

Source from the content-addressed store, hash-verified

663 * Remove the .codegraph directory
664 */
665export 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

Callers 1

uninitializeMethod · 0.90

Calls 1

getCodeGraphDirFunction · 0.85

Tested by

no test coverage detected