conventional-recommended-bump.js 675 B

123456789101112131415161718192021222324252627282930313233
  1. 'use strict'
  2. const parserOpts = require('./parser-opts')
  3. module.exports = {
  4. parserOpts,
  5. whatBump: (commits) => {
  6. let level = 2
  7. let breakings = 0
  8. let features = 0
  9. commits.forEach(commit => {
  10. if (commit.notes.length > 0) {
  11. breakings += commit.notes.length
  12. level = 0
  13. } else if (commit.type === 'feat') {
  14. features += 1
  15. if (level === 2) {
  16. level = 1
  17. }
  18. }
  19. })
  20. return {
  21. level: level,
  22. reason: breakings === 1
  23. ? `There is ${breakings} BREAKING CHANGE and ${features} features`
  24. : `There are ${breakings} BREAKING CHANGES and ${features} features`
  25. }
  26. }
  27. }