-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
54 lines (51 loc) · 1.41 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"use strict";
const Q = require(`q`);
// eslint-disable-next-line @typescript-eslint/naming-convention
const _ = require(`lodash`);
const conventionalChangelog = require(`./conventional-changelog`);
const parserOpts = require(`./parser-opts`);
const recommendedBumpOpts = require(`./conventional-recommended-bump`);
const writerOpts = require(`./writer-opts`);
module.exports = function (parameter) {
// parameter passed can be either a config object or a callback function
if (_.isFunction(parameter)) {
// parameter is a callback object
const config = {};
Q.all([
conventionalChangelog,
parserOpts,
recommendedBumpOpts,
writerOpts(config),
]).spread(
(conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts) => {
parameter(null, {
conventionalChangelog,
gitRawCommitsOpts: { noMerges: null },
parserOpts,
recommendedBumpOpts,
writerOpts,
});
}
);
} else {
const config = parameter || {};
return presetOpts(config);
}
};
function presetOpts(config) {
return Q.all([
conventionalChangelog,
parserOpts,
recommendedBumpOpts,
writerOpts(config),
]).spread(
(conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts) => {
return {
conventionalChangelog,
parserOpts,
recommendedBumpOpts,
writerOpts,
};
}
);
}