conventional-recommended-bump.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. 'use strict'
  2. const addBangNotes = require('./add-bang-notes')
  3. const parserOpts = require('./parser-opts')
  4. module.exports = function (config) {
  5. return {
  6. parserOpts: parserOpts(config),
  7. whatBump: (commits) => {
  8. let level = 2
  9. let breakings = 0
  10. let features = 0
  11. commits.forEach(commit => {
  12. // adds additional breaking change notes
  13. // for the special case, test(system)!: hello world, where there is
  14. // a '!' but no 'BREAKING CHANGE' in body:
  15. addBangNotes(commit)
  16. if (commit.notes.length > 0) {
  17. breakings += commit.notes.length
  18. level = 0
  19. } else if (commit.type === 'feat' || commit.type === 'feature') {
  20. features += 1
  21. if (level === 2) {
  22. level = 1
  23. }
  24. }
  25. })
  26. if (config.preMajor && level < 2) {
  27. level++
  28. }
  29. return {
  30. level: level,
  31. reason: breakings === 1
  32. ? `There is ${breakings} BREAKING CHANGE and ${features} features`
  33. : `There are ${breakings} BREAKING CHANGES and ${features} features`
  34. }
  35. }
  36. }
  37. }