(text)
| 147 | // have subsections, [include] directives, etc. |
| 148 | export class GitConfig { |
| 149 | constructor(text) { |
| 150 | let section = null |
| 151 | let subsection = null |
| 152 | this.parsedConfig = text |
| 153 | ? text.split('\n').map(line => { |
| 154 | let name = null |
| 155 | let value = null |
| 156 | |
| 157 | const trimmedLine = line.trim() |
| 158 | const extractedSection = extractSectionLine(trimmedLine) |
| 159 | const isSection = extractedSection != null |
| 160 | if (isSection) { |
| 161 | ;[section, subsection] = extractedSection |
| 162 | } else { |
| 163 | const extractedVariable = extractVariableLine(trimmedLine) |
| 164 | const isVariable = extractedVariable != null |
| 165 | if (isVariable) { |
| 166 | ;[name, value] = extractedVariable |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | const path = getPath(section, subsection, name) |
| 171 | return { line, isSection, section, subsection, name, value, path } |
| 172 | }) |
| 173 | : [] |
| 174 | } |
| 175 | |
| 176 | static from(text) { |
| 177 | return new GitConfig(text) |
nothing calls this directly
no test coverage detected