(path: string)
| 181 | * @returns Parsed settings data and validation errors |
| 182 | */ |
| 183 | export function parseSettingsFile(path: string): { |
| 184 | settings: SettingsJson | null |
| 185 | errors: ValidationError[] |
| 186 | } { |
| 187 | const cached = getCachedParsedFile(path) |
| 188 | if (cached) { |
| 189 | // Clone so callers (e.g. mergeWith in getSettingsForSourceUncached, |
| 190 | // updateSettingsForSource) can't mutate the cached entry. |
| 191 | return { |
| 192 | settings: cached.settings ? clone(cached.settings) : null, |
| 193 | errors: cached.errors, |
| 194 | } |
| 195 | } |
| 196 | const result = parseSettingsFileUncached(path) |
| 197 | setCachedParsedFile(path, result) |
| 198 | // Clone the first return too — the caller may mutate before |
| 199 | // another caller reads the same cache entry. |
| 200 | return { |
| 201 | settings: result.settings ? clone(result.settings) : null, |
| 202 | errors: result.errors, |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | function parseSettingsFileUncached(path: string): { |
| 207 | settings: SettingsJson | null |
no test coverage detected