-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
50 lines (43 loc) · 1.2 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
#!/usr/bin/env node
const handle = require('./lib/handle');
const args = process.argv;
args.splice(0, 2);
(args => {
const config = {};
while(args.length)
{
const arg = args.shift();
switch(arg)
{
case '--version':
case '-v':
config.diplayVersion = true;
break;
case '--changes':
case '-c':
config.diplayChanges = true;
break;
case '--today':
config.releaseToday = true;
break;
// case '--strict':
// config.strict = true;
// break;
default:
config.path = arg;
}
}
if(!config.path)
return console.error('Please specify the path to a changelog file.');
handle(config).then(parser => {
if(!parser.isValid)
{
parser.errors.forEach(({message}) => console.error(message));
return process.exit(1);
}
if(config.diplayVersion)
console.log(parser.latestRelease.version);
if(config.diplayChanges)
console.log(parser.getLatestChanges());
});
})(args);