* Retrieve the changelog entries for the provide changelog path, if the file does not exist an * empty array is returned.
(path: string)
| 171 | * empty array is returned. |
| 172 | */ |
| 173 | private getEntriesFor(path: string): ChangelogEntry[] { |
| 174 | if (!existsSync(path)) { |
| 175 | return []; |
| 176 | } |
| 177 | |
| 178 | return ( |
| 179 | readFileSync(path, {encoding: 'utf8'}) |
| 180 | // Use the versionMarker as the separator for .split(). |
| 181 | .split(splitMarker) |
| 182 | // If the `split()` method finds the separator at the beginning or end of a string, it |
| 183 | // includes an empty string at the respective locaiton, so we filter to remove all of these |
| 184 | // potential empty strings. |
| 185 | .filter((entry) => entry.trim().length !== 0) |
| 186 | // Create a ChangelogEntry for each of the string entry. |
| 187 | .map(parseChangelogEntry) |
| 188 | ); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | /** Parse the provided string into a ChangelogEntry object. */ |
no outgoing calls
no test coverage detected