Skip to content

Commit

Permalink
markdown-renderer: Simplify renderMarkdown() implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Nov 30, 2019
1 parent abc8b74 commit fe1253c
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/markdown-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,12 @@ export default class MarkdownRenderer {
}

public renderMarkdown(releases: Release[]) {
let renderedString = releases
let output = releases
.map(release => this.renderRelease(release))
.filter(Boolean)
.reduce((previousValue, currentValue, index, array) => {
let finalValue = "";
finalValue = finalValue.concat(previousValue || "");
finalValue = finalValue.concat("\n");
finalValue = finalValue.concat(currentValue || "");
if (index !== array.length - 1) {
finalValue = finalValue.concat("\n\n");
}
return finalValue;
}, "");

return `${renderedString}`;
.join("\n\n\n");

return output ? `\n${output}` : '';
}

public renderRelease(release: Release): string | undefined {
Expand Down

0 comments on commit fe1253c

Please sign in to comment.