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

Function createDirectory

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

Source from the content-addressed store, hash-verified

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