MCPcopy
hub / github.com/colbymchenry/codegraph / createDirectory

Function createDirectory

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

Source from the content-addressed store, hash-verified

446 * Note: Only throws if codegraph.db already exists, not just if .codegraph/ exists.
447 */
448export function createDirectory(projectRoot: string): void {
449 const codegraphDir = getCodeGraphDir(projectRoot);
450 const dbPath = path.join(codegraphDir, 'codegraph.db');
451
452 // Only throw if CodeGraph is actually initialized (db exists)
453 // .codegraph/ folder alone is fine
454 if (fs.existsSync(dbPath)) {
455 throw new Error(`CodeGraph already initialized in ${projectRoot}`);
456 }
457
458 // Create main directory (if it doesn't exist)
459 fs.mkdirSync(codegraphDir, { recursive: true });
460
461 // Write .gitignore inside .codegraph (create if absent, upgrade a stale
462 // pre-wildcard default left by an older version — issue #788).
463 ensureGitignore(path.join(codegraphDir, '.gitignore'));
464}
465
466/**
467 * Remove the .codegraph directory

Callers 2

initMethod · 0.90
initSyncMethod · 0.90

Calls 3

getCodeGraphDirFunction · 0.85
ensureGitignoreFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected