(projectRoot: string)
| 1017 | * Note: Only throws if codegraph.db already exists, not just if .codegraph/ exists. |
| 1018 | */ |
| 1019 | export 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 |
no test coverage detected