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