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

Function createDirectory

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

Source from the content-addressed store, hash-verified

701 * Note: Only throws if codegraph.db already exists, not just if .codegraph/ exists.
702 */
703export function createDirectory(projectRoot: string): void {
704 const codegraphDir = getCodeGraphDir(projectRoot);
705 const dbPath = path.join(codegraphDir, 'codegraph.db');
706
707 // Only throw if CodeGraph is actually initialized (db exists)
708 // .codegraph/ folder alone is fine
709 if (fs.existsSync(dbPath)) {
710 throw new Error(`CodeGraph already initialized in ${projectRoot}`);
711 }
712
713 // Create main directory (if it doesn't exist)
714 fs.mkdirSync(codegraphDir, { recursive: true });
715
716 // Write .gitignore inside .codegraph (create if absent, upgrade a stale
717 // pre-wildcard default left by an older version — issue #788).
718 ensureGitignore(path.join(codegraphDir, '.gitignore'));
719}
720
721/**
722 * 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