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

Function createDirectory

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

Source from the content-addressed store, hash-verified

642 * Note: Only throws if codegraph.db already exists, not just if .codegraph/ exists.
643 */
644export function createDirectory(projectRoot: string): void {
645 const codegraphDir = getCodeGraphDir(projectRoot);
646 const dbPath = path.join(codegraphDir, 'codegraph.db');
647
648 // Only throw if CodeGraph is actually initialized (db exists)
649 // .codegraph/ folder alone is fine
650 if (fs.existsSync(dbPath)) {
651 throw new Error(`CodeGraph already initialized in ${projectRoot}`);
652 }
653
654 // Create main directory (if it doesn't exist)
655 fs.mkdirSync(codegraphDir, { recursive: true });
656
657 // Write .gitignore inside .codegraph (create if absent, upgrade a stale
658 // pre-wildcard default left by an older version — issue #788).
659 ensureGitignore(path.join(codegraphDir, '.gitignore'));
660}
661
662/**
663 * Remove the .codegraph directory

Callers 2

initMethod · 0.90
initSyncMethod · 0.90

Calls 3

getCodeGraphDirFunction · 0.85
ensureGitignoreFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected