( options: PersistenceTargetOptions, )
| 271 | } |
| 272 | |
| 273 | async function readBaseConfigForPersistence( |
| 274 | options: PersistenceTargetOptions, |
| 275 | ): Promise<ProjectConfig> { |
| 276 | if (!options.fs.existsSync(options.configPath)) { |
| 277 | return { schemaVersion: 1 }; |
| 278 | } |
| 279 | |
| 280 | try { |
| 281 | const rawText = await options.fs.readFile(options.configPath, 'utf8'); |
| 282 | const parsed = parseProjectConfig(rawText); |
| 283 | return { ...normalizeConfigForPersistence(parsed), schemaVersion: 1 }; |
| 284 | } catch (error) { |
| 285 | const errorMessage = error instanceof Error ? error.message : String(error); |
| 286 | log( |
| 287 | 'warn', |
| 288 | `Failed to read or parse project config at ${options.configPath}. Overwriting with new config. ${errorMessage}`, |
| 289 | ); |
| 290 | return { schemaVersion: 1 }; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | export async function loadProjectConfig( |
| 295 | options: LoadProjectConfigOptions, |
no test coverage detected