Skip to content
This repository was archived by the owner on Feb 5, 2018. It is now read-only.

Commit 60def39

Browse files
committed
feat(exports): export the promise
1 parent dbc5272 commit 60def39

File tree

2 files changed

+63
-67
lines changed

2 files changed

+63
-67
lines changed

index.js

+62-66
Original file line numberDiff line numberDiff line change
@@ -4,77 +4,73 @@ var Q = require('q');
44
var readFile = Q.denodeify(require('fs').readFile);
55
var resolve = require('path').resolve;
66

7-
function presetOpts() {
8-
var parserOpts = {
9-
headerPattern: /^(\w*)(?:\((.*)\))?\: (.*)$/,
10-
headerCorrespondence: [
11-
'type',
12-
'scope',
13-
'subject'
14-
],
15-
noteKeywords: 'BREAKING CHANGE',
16-
revertPattern: /^revert:\s([\s\S]*?)\s*This reverts commit (\w*)\./,
17-
revertCorrespondence: ['header', 'hash']
18-
};
7+
var parserOpts = {
8+
headerPattern: /^(\w*)(?:\((.*)\))?\: (.*)$/,
9+
headerCorrespondence: [
10+
'type',
11+
'scope',
12+
'subject'
13+
],
14+
noteKeywords: 'BREAKING CHANGE',
15+
revertPattern: /^revert:\s([\s\S]*?)\s*This reverts commit (\w*)\./,
16+
revertCorrespondence: ['header', 'hash']
17+
};
1918

20-
var writerOpts = {
21-
transform: function(commit) {
22-
if (commit.type === 'feat') {
23-
commit.type = 'Features';
24-
} else if (commit.type === 'fix') {
25-
commit.type = 'Bug Fixes';
26-
} else if (commit.type === 'perf') {
27-
commit.type = 'Performance Improvements';
28-
} else if (commit.type === 'revert') {
29-
commit.type = 'Reverts';
30-
} else {
31-
return;
32-
}
33-
34-
if (commit.scope === '*') {
35-
commit.scope = '';
36-
}
19+
var writerOpts = {
20+
transform: function(commit) {
21+
if (commit.type === 'feat') {
22+
commit.type = 'Features';
23+
} else if (commit.type === 'fix') {
24+
commit.type = 'Bug Fixes';
25+
} else if (commit.type === 'perf') {
26+
commit.type = 'Performance Improvements';
27+
} else if (commit.type === 'revert') {
28+
commit.type = 'Reverts';
29+
} else {
30+
return;
31+
}
3732

38-
if (typeof commit.hash === 'string') {
39-
commit.hash = commit.hash.substring(0, 7);
40-
}
33+
if (commit.scope === '*') {
34+
commit.scope = '';
35+
}
4136

42-
if (typeof commit.subject === 'string') {
43-
commit.subject = commit.subject.substring(0, 80);
44-
}
37+
if (typeof commit.hash === 'string') {
38+
commit.hash = commit.hash.substring(0, 7);
39+
}
4540

46-
commit.notes.forEach(function(note) {
47-
if (note.title === 'BREAKING CHANGE') {
48-
note.title = 'BREAKING CHANGES';
49-
}
50-
});
41+
if (typeof commit.subject === 'string') {
42+
commit.subject = commit.subject.substring(0, 80);
43+
}
5144

52-
return commit;
53-
},
54-
groupBy: 'type',
55-
commitGroupsSort: 'title',
56-
commitsSort: ['scope', 'subject'],
57-
noteGroupsSort: 'title',
58-
notesSort: compareFunc
59-
};
45+
commit.notes.forEach(function(note) {
46+
if (note.title === 'BREAKING CHANGE') {
47+
note.title = 'BREAKING CHANGES';
48+
}
49+
});
6050

61-
return Q.all([
62-
readFile(resolve(__dirname, 'templates/template.hbs'), 'utf-8'),
63-
readFile(resolve(__dirname, 'templates/header.hbs'), 'utf-8'),
64-
readFile(resolve(__dirname, 'templates/commit.hbs'), 'utf-8'),
65-
readFile(resolve(__dirname, 'templates/footer.hbs'), 'utf-8')
66-
])
67-
.spread(function(template, header, commit, footer) {
68-
writerOpts.mainTemplate = template;
69-
writerOpts.headerPartial = header;
70-
writerOpts.commitPartial = commit;
71-
writerOpts.footerPartial = footer;
51+
return commit;
52+
},
53+
groupBy: 'type',
54+
commitGroupsSort: 'title',
55+
commitsSort: ['scope', 'subject'],
56+
noteGroupsSort: 'title',
57+
notesSort: compareFunc
58+
};
7259

73-
return {
74-
parserOpts: parserOpts,
75-
writerOpts: writerOpts
76-
};
77-
});
78-
}
60+
module.exports = Q.all([
61+
readFile(resolve(__dirname, 'templates/template.hbs'), 'utf-8'),
62+
readFile(resolve(__dirname, 'templates/header.hbs'), 'utf-8'),
63+
readFile(resolve(__dirname, 'templates/commit.hbs'), 'utf-8'),
64+
readFile(resolve(__dirname, 'templates/footer.hbs'), 'utf-8')
65+
])
66+
.spread(function(template, header, commit, footer) {
67+
writerOpts.mainTemplate = template;
68+
writerOpts.headerPartial = header;
69+
writerOpts.commitPartial = commit;
70+
writerOpts.footerPartial = footer;
7971

80-
module.exports = presetOpts;
72+
return {
73+
parserOpts: parserOpts,
74+
writerOpts: writerOpts
75+
};
76+
});

test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use strict';
22
var child = require('child_process');
33
var conventionalChangelogCore = require('conventional-changelog-core');
4+
var preset = require('./');
45
var expect = require('chai').expect;
56
var gitDummyCommit = require('git-dummy-commit');
67
var shell = require('shelljs');
78
var through = require('through2');
8-
var preset = require('./')();
99

1010
describe('angular preset', function() {
1111
before(function(done) {

0 commit comments

Comments
 (0)