This repository was archived by the owner on Jun 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
56 lines (43 loc) · 1.32 KB
/
index.js
File metadata and controls
56 lines (43 loc) · 1.32 KB
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
'use strict';
var path = require('path');
var chalk = require('chalk');
var stripEof = require('strip-eof');
var H = require('./helpers');
module.exports = function (opts) {
opts = opts || {};
H.verbose = opts.verbose;
H.section('Checking git repository');
H.checkGitExec();
var base = opts.base && opts.base.trim();
if (base) {
base = path.resolve(process.cwd(), base);
H.checkDirectory(base);
H.log('Changing working directory to ' + chalk.cyan(base) + '.');
process.chdir(base);
} else {
H.log('Using the current working directory as the base.');
}
H.checkGitRepo();
H.section('Checking preset');
var preset = opts.preset ? opts.preset.trim() : '';
var formater;
if (preset) {
try {
formater = require('./presets/' + preset.toLowerCase());
} catch (err) {
H.error('ERROR: Preset `' + preset + '` doesn\'t exist', 1);
}
H.log('Using ' + preset + ' preset.');
} else {
H.log('Using default preset.');
formater = H.format;
}
H.section('Gathering commits');
var commitish = opts.commitish ? opts.commitish.trim() : '';
var commits = H.getLog(commitish, formater.format).split(/\r?\n/);
H.section('Generating changelog');
var output = H.getHeader(formater.header, H.getVersion(opts.release));
output += formater(commits);
H.log(chalk.green('Done!') + '\n');
return stripEof(output);
};