(configPath: string)
| 27 | } |
| 28 | |
| 29 | async function readJsonObjectSafe(configPath: string): Promise<JsonObject> { |
| 30 | if (!(await pathExists(configPath))) { |
| 31 | return {} |
| 32 | } |
| 33 | |
| 34 | try { |
| 35 | const parsed = await readJson<unknown>(configPath) |
| 36 | if (isJsonObject(parsed)) { |
| 37 | return parsed |
| 38 | } |
| 39 | } catch { |
| 40 | // Fall through to warning and replacement. |
| 41 | } |
| 42 | |
| 43 | console.warn( |
| 44 | `Warning: existing ${path.basename(configPath)} could not be parsed and will be replaced.`, |
| 45 | ) |
| 46 | return {} |
| 47 | } |
no test coverage detected