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

Function createDirectory

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

Source from the content-addressed store, hash-verified

1017 * Note: Only throws if codegraph.db already exists, not just if .codegraph/ exists.
1018 */
1019export function createDirectory(projectRoot: string): void {
1020 const codegraphDir = getCodeGraphDir(projectRoot);
1021
1022 // Only throw if CodeGraph is actually initialized (db with a schema).
1023 // .codegraph/ folder alone — or a schema-less codegraph.db left by an
1024 // interrupted init (#1895) — is fine: initialize() adds the schema to it.
1025 if (isInitialized(projectRoot)) {
1026 throw new Error(`CodeGraph already initialized in ${projectRoot}`);
1027 }
1028
1029 // Create main directory (if it doesn't exist)
1030 fs.mkdirSync(codegraphDir, { recursive: true });
1031
1032 // Write .gitignore inside .codegraph (create if absent, upgrade a stale
1033 // pre-wildcard default left by an older version — issue #788).
1034 ensureGitignore(path.join(codegraphDir, '.gitignore'));
1035}
1036
1037/**
1038 * Remove the .codegraph directory

Callers 2

initMethod · 0.90
initSyncMethod · 0.90

Calls 4

getCodeGraphDirFunction · 0.85
isInitializedFunction · 0.85
ensureGitignoreFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected