Skip to content

Commit

Permalink
[Fix] Do not print empty keys in result
Browse files Browse the repository at this point in the history
  • Loading branch information
jtouzy committed Mar 31, 2021
1 parent a56300d commit 546d3a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions generators/Markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = class Markdown {
return Object.assign(result, { [key]: [] })
}, {})
// Sorting commits by keys
const evaluatedGroups = commits.reduce((previousGroups, commit) => {
commits.reduce((previousGroups, commit) => {
const message = commit.message
const markStart = message.indexOf('[')
const markEnd = message.indexOf(']')
Expand All @@ -30,8 +30,12 @@ module.exports = class Markdown {
`[Différence avec la version ${oldTag}](https://github.com/${owner}/${repo}/compare/${oldTag}...${newTag})`
]
searchableKeys.forEach(key => {
const commitsForKey = commitGroups[key]
if (commitsForKey.length === 0) {
return
}
result.push(`## ${keysObject[key]}`)
commitGroups[key].forEach(commit => result.push(commit))
commitsForKey.forEach(commit => result.push(commit))
})
return result.join('\n')
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pictarine/release-note-now",
"version": "1.0.4",
"version": "1.0.5",
"description": "Automatic release note generator for GitHub projects",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 546d3a3

Please sign in to comment.