Parse the provided string into a ChangelogEntry object.
(content: string)
| 191 | |
| 192 | /** Parse the provided string into a ChangelogEntry object. */ |
| 193 | function parseChangelogEntry(content: string): ChangelogEntry { |
| 194 | const versionMatcherResult = versionAnchorMatcher.exec(content); |
| 195 | if (versionMatcherResult === null) { |
| 196 | throw Error(`Unable to determine version for changelog entry: ${content}`); |
| 197 | } |
| 198 | const version = semver.parse(versionMatcherResult[1]); |
| 199 | |
| 200 | if (version === null) { |
| 201 | throw Error( |
| 202 | `Unable to determine version for changelog entry, with tag: ${versionMatcherResult[1]}`, |
| 203 | ); |
| 204 | } |
| 205 | |
| 206 | return { |
| 207 | content: content.trim(), |
| 208 | version, |
| 209 | }; |
| 210 | } |
no test coverage detected