index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. 'use strict'
  2. const Q = require('q')
  3. const _ = require('lodash')
  4. const conventionalChangelog = require('./conventional-changelog')
  5. const parserOpts = require('./parser-opts')
  6. const recommendedBumpOpts = require('./conventional-recommended-bump')
  7. const writerOpts = require('./writer-opts')
  8. module.exports = function (parameter) {
  9. // parameter passed can be either a config object or a callback function
  10. if (_.isFunction(parameter)) {
  11. // parameter is a callback object
  12. const config = {}
  13. // FIXME: use presetOpts(config) for callback
  14. Q.all([
  15. conventionalChangelog(config),
  16. parserOpts(config),
  17. recommendedBumpOpts(config),
  18. writerOpts(config)
  19. ]).spread((conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts) => {
  20. parameter(null, { gitRawCommitsOpts: { noMerges: null }, conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts })
  21. })
  22. } else {
  23. const config = parameter || {}
  24. return presetOpts(config)
  25. }
  26. }
  27. function presetOpts (config) {
  28. return Q.all([
  29. conventionalChangelog(config),
  30. parserOpts(config),
  31. recommendedBumpOpts(config),
  32. writerOpts(config)
  33. ]).spread((conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts) => {
  34. return { conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts }
  35. })
  36. }