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