1 | ;
|
2 |
|
3 | var Bluebird = require('bluebird');
|
4 |
|
5 | var Git = require('./git');
|
6 | var Package = require('./package');
|
7 | var Writer = require('./writer');
|
8 |
|
9 | /**
|
10 | * Generate the changelog.
|
11 | * @param {Object} options - generation options
|
12 | * @param {Boolean} options.patch - whether it should be a patch changelog
|
13 | * @param {Boolean} options.minor - whether it should be a minor changelog
|
14 | * @param {Boolean} options.major - whether it should be a major changelog
|
15 | * @param {String} options.repoUrl - repo URL that will be used when linking commits
|
16 | * @returns {Promise<String>} the \n separated changelog string
|
17 | */
|
18 | exports.generate = function (options) {
|
19 | return Bluebird.all([
|
20 | Package.extractRepoUrl(),
|
21 | Package.calculateNewVersion(options),
|
22 | Git.getCommits()
|
23 | ])
|
24 | .spread(function (repoUrl, version, commits) {
|
25 | options.repoUrl = options.repoUrl || repoUrl;
|
26 |
|
27 | return Writer.markdown(version, commits, options);
|
28 | });
|
29 | };
|