semantic-release/src/lib/analyzer.js
2015-06-12 13:50:51 -07:00

27 lines
488 B
JavaScript

const { parseRawCommit } = require('conventional-changelog/lib/git')
module.exports = function (commits) {
let type = null
commits
.map((commit) => parseRawCommit(`${commit.hash}\n${commit.message}`))
.filter((commit) => !!commit)
.every((commit) => {
if (commit.breaks.length) {
type = 'major'
return false
}
if (commit.type === 'feat') type = 'minor'
if (!type && commit.type === 'fix') type = 'patch'
return true
})
return type
}