(projectRoot: string, subdirName: string)
| 1137 | * Ensure a subdirectory exists within .codegraph |
| 1138 | */ |
| 1139 | export function ensureSubdirectory(projectRoot: string, subdirName: string): string { |
| 1140 | if (subdirName.includes('..') || subdirName.includes(path.sep) || subdirName.includes('/')) { |
| 1141 | throw new Error(`Invalid subdirectory name: ${subdirName}`); |
| 1142 | } |
| 1143 | |
| 1144 | const subdirPath = path.join(getCodeGraphDir(projectRoot), subdirName); |
| 1145 | |
| 1146 | if (!fs.existsSync(subdirPath)) { |
| 1147 | fs.mkdirSync(subdirPath, { recursive: true }); |
| 1148 | } |
| 1149 | |
| 1150 | return subdirPath; |
| 1151 | } |
| 1152 | |
| 1153 | /** |
| 1154 | * Check if the .codegraph directory has valid structure |
nothing calls this directly
no test coverage detected