Skip to content

Commit

Permalink
feat: sort sections of CHANGELOG based on priority (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Sep 5, 2019
1 parent 6425972 commit a3acc32
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -37,6 +37,7 @@
},
"scripts": {
"lint": "eslint . --cache --cache-location ./node_modules/.cache/ --ignore-path .gitignore",
"fix": "eslint . --fix --cache --cache-location ./node_modules/.cache/ --ignore-path .gitignore",
"pretest": "npm run lint",
"test": "nyc mocha --timeout 30000 packages/*/test{,/*}.js",
"test-windows": "lerna exec --concurrency 1 -- npm run test-windows",
Expand Down
Expand Up @@ -113,6 +113,14 @@ describe('conventionalcommits.org preset', function () {
expect(chunk).to.not.include('***:**')
expect(chunk).to.not.include(': Not backward compatible.')

// CHANGELOG should group sections in order of importance:
expect(
chunk.indexOf('BREAKING CHANGE') < chunk.indexOf('Features') &&
chunk.indexOf('Features') < chunk.indexOf('Bug Fixes') &&
chunk.indexOf('Bug Fixes') < chunk.indexOf('Performance Improvements') &&
chunk.indexOf('Performance Improvements') < chunk.indexOf('Reverts')
).to.equal(true)

done()
}))
})
Expand Down
Expand Up @@ -138,7 +138,18 @@ function getWriterOpts (config) {
return commit
},
groupBy: `type`,
commitGroupsSort: `title`,
// the groupings of commit messages, e.g., Features vs., Bug Fixes, are
// sorted based on their probable importance:
commitGroupsSort: (a, b) => {
const commitGroupOrder = ['Reverts', 'Performance Improvements', 'Bug Fixes', 'Features']
const gRankA = commitGroupOrder.indexOf(a.title)
const gRankB = commitGroupOrder.indexOf(b.title)
if (gRankA >= gRankB) {
return -1
} else {
return 1
}
},
commitsSort: [`scope`, `subject`],
noteGroupsSort: `title`,
notesSort: compareFunc
Expand Down

0 comments on commit a3acc32

Please sign in to comment.