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

Function removeDirectory

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

Source from the content-addressed store, hash-verified

722 * Remove the .codegraph directory
723 */
724export 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

Callers 1

uninitializeMethod · 0.90

Calls 1

getCodeGraphDirFunction · 0.85

Tested by

no test coverage detected