(projectRoot: string, subdirName: string)
| 566 | * Ensure a subdirectory exists within .codegraph |
| 567 | */ |
| 568 | export function ensureSubdirectory(projectRoot: string, subdirName: string): string { |
| 569 | if (subdirName.includes('..') || subdirName.includes(path.sep) || subdirName.includes('/')) { |
| 570 | throw new Error(`Invalid subdirectory name: ${subdirName}`); |
| 571 | } |
| 572 | |
| 573 | const subdirPath = path.join(getCodeGraphDir(projectRoot), subdirName); |
| 574 | |
| 575 | if (!fs.existsSync(subdirPath)) { |
| 576 | fs.mkdirSync(subdirPath, { recursive: true }); |
| 577 | } |
| 578 | |
| 579 | return subdirPath; |
| 580 | } |
| 581 | |
| 582 | /** |
| 583 | * Check if the .codegraph directory has valid structure |
nothing calls this directly
no test coverage detected