This repository has been archived by the owner on Nov 21, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
69 lines (61 loc) · 1.7 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
'use strict';
var Q = require('q');
var readFile = Q.denodeify(require('fs').readFile);
var resolve = require('path').resolve;
function presetOpts(cb) {
var parserOpts = {
mergePattern: /^Merge pull request #(.*) from .*$/,
mergeCorrespondence: ['pr'],
headerPattern: /^\[(.*) (.*)] (.*)$/,
headerCorrespondence: [
'tag',
'taggedAs',
'message'
]
};
var writerOpts = {
transform: function(commit) {
if (!commit.pr) {
return;
}
if (commit.tag === 'BUGFIX') {
commit.tag = 'Bug Fixes';
} else if (commit.tag === 'CLEANUP') {
commit.tag = 'Cleanup';
} else if (commit.tag === 'FEATURE') {
commit.tag = 'Features';
} else if (commit.tag === 'DOC') {
commit.tag = 'Documentation';
} else if (commit.tag === 'SECURITY') {
commit.tag = 'Security';
} else {
return;
}
if (typeof commit.hash === 'string') {
commit.hash = commit.hash.substring(0, 7);
}
return commit;
},
groupBy: 'tag',
commitGroupsSort: 'title',
commitsSort: ['tag', 'taggedAs', 'message']
};
Q.all([
readFile(resolve(__dirname, 'templates/template.hbs'), 'utf-8'),
readFile(resolve(__dirname, 'templates/header.hbs'), 'utf-8'),
readFile(resolve(__dirname, 'templates/commit.hbs'), 'utf-8')
])
.spread(function(template, header, commit) {
writerOpts.mainTemplate = template;
writerOpts.headerPartial = header;
writerOpts.commitPartial = commit;
cb(null, {
gitRawCommitsOpts: {
noMerges: null
},
parserOpts: parserOpts,
writerOpts: writerOpts
});
});
}
module.exports = presetOpts;