(filePath: string)
| 46 | } |
| 47 | |
| 48 | function loadYamlFile(filePath: string): LoadedYamlFile { |
| 49 | if (!existsSync(filePath)) { |
| 50 | return { value: null, path: filePath, source: null, doc: null }; |
| 51 | } |
| 52 | let raw: string; |
| 53 | try { |
| 54 | raw = readFileSync(filePath, 'utf-8'); |
| 55 | } catch (err) { |
| 56 | console.warn( |
| 57 | `[config] Failed to read ${filePath}: ${err instanceof Error ? err.message : err}`, |
| 58 | ); |
| 59 | return { value: null, path: filePath, source: null, doc: null }; |
| 60 | } |
| 61 | const doc = parseDocument(raw); |
| 62 | if (doc.errors.length > 0) { |
| 63 | console.warn( |
| 64 | `[config] Failed to parse ${filePath}: ${doc.errors.map((e) => e.message).join('; ')}`, |
| 65 | ); |
| 66 | return { value: null, path: filePath, source: raw, doc: null }; |
| 67 | } |
| 68 | const parsed = doc.toJSON(); |
| 69 | if (isObject(parsed)) { |
| 70 | return { value: parsed, path: filePath, source: raw, doc }; |
| 71 | } |
| 72 | return { value: null, path: filePath, source: raw, doc }; |
| 73 | } |
| 74 | |
| 75 | function annotateIssuesWithSource( |
| 76 | zodIssues: ReadonlyArray<{ path: PropertyKey[]; message: string; code: string }>, |
no test coverage detected