Skip to content

Commit

Permalink
fix(deps): adjust changes of the latest parse-commit-message
Browse files Browse the repository at this point in the history
Signed-off-by: Charlike Mike Reagent <olsten.larck@gmail.com>
  • Loading branch information
Charlike Mike Reagent committed Feb 12, 2018
1 parent 97c55e1 commit 506268f
Showing 1 changed file with 2 additions and 29 deletions.
31 changes: 2 additions & 29 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @license Apache-2.0
*/

const parseCommitMessage = require('parse-commit-message')
const { parse, plugins } = require('parse-commit-message')

/**
* > Parses given `commitMessage` and returns an **"increment" type**,
Expand Down Expand Up @@ -46,33 +46,6 @@ const parseCommitMessage = require('parse-commit-message')
*/

module.exports = function detectNextVersion (commitMessage, full) {
const result = parseCommitMessage(commitMessage, incrementMapper)
const result = parse(commitMessage, plugins)
return full === true ? result : result.increment
}

function incrementMapper (commit) {
const isBreaking = isBreakingChange(commit)
let increment = null

if (/fix|bugfix|patch/.test(commit.type)) {
increment = 'patch'
}
if (/feat|feature|minor/.test(commit.type)) {
increment = 'minor'
}
if (/break|breaking|major/.test(commit.type) || isBreaking) {
increment = 'major'
}

return Object.assign({}, commit, { increment, isBreaking })
}

/* eslint-disable no-param-reassign */

function isBreakingChange ({ subject, body, footer }) {
body = body || ''
footer = footer || ''

const re = 'BREAKING CHANGE:'
return subject.includes(re) || body.includes(re) || footer.includes(re)
}

0 comments on commit 506268f

Please sign in to comment.