-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcli.js
executable file
·50 lines (38 loc) · 964 Bytes
/
cli.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
var fs = require('fs');
var upath = require('upath');
var meow = require('meow');
var verifyChangelog = require('./index');
var cli = meow(`
Usage
$ changelog-verify <filename>
Options
--unreleased Verify that the unreleased section has been modified.
(default: false)
<filename> defaults to CHANGELOG.md
`, {
flags: {
unreleased: {
type: 'boolean',
default: false
}
}
});
var fileName = cli.input[0] || 'CHANGELOG.md';
if (!upath.isAbsolute(fileName)) {
fileName = upath.normalize(upath.join(process.cwd(), fileName));
}
try {
var data = fs.readFileSync(fileName, 'utf8');
verifyChangelog(data, cli.flags.unreleased, function(error) {
if (error) {
console.error(error);
process.exit(1);
}
process.exit(0);
});
} catch (error) {
// eslint-disable-next-line no-console
console.error(error.message || error.toString());
process.exit(1);
}