(content)
| 108 | } |
| 109 | |
| 110 | function parseTomlConfig(content) { |
| 111 | const out = {}; |
| 112 | let section = []; |
| 113 | for (const rawLine of content.split('\n')) { |
| 114 | const line = rawLine.trim(); |
| 115 | if (!line || line.startsWith('#')) continue; |
| 116 | const sectionMatch = line.match(/^\[([^\]]+)\]$/); |
| 117 | if (sectionMatch) { |
| 118 | section = sectionMatch[1].split('.').map(s => s.trim()).filter(Boolean); |
| 119 | continue; |
| 120 | } |
| 121 | const kv = line.match(/^([A-Za-z0-9_-]+)\s*=\s*(.+)$/); |
| 122 | if (!kv) continue; |
| 123 | let cursor = out; |
| 124 | for (const part of section) { |
| 125 | if (!cursor[part] || typeof cursor[part] !== 'object') cursor[part] = {}; |
| 126 | cursor = cursor[part]; |
| 127 | } |
| 128 | cursor[kv[1]] = parseTomlValue(kv[2]); |
| 129 | } |
| 130 | return out; |
| 131 | } |
| 132 | |
| 133 | function coerceModelEntry(value) { |
| 134 | if (!value) return {}; |
no test coverage detected