-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
executable file
·50 lines (42 loc) · 1.27 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
// 3rd party modules
const chalk = require('chalk');
const {program} = require('commander');
// Modules
const c = require('./src/lib/console');
const commitRelease = require('./src/commit-release');
// Implementation
program
.version(require('./package.json').version)
.option('-f, --force', 'overwrite tag if it exists already')
.option('-n, --no-verify', 'skip git commit hooks')
.option('-o, --override [version]', 'override recommended version number', '')
.option('-p, --postfix [name]', 'a postfix such as "rc1", "canary" or "beta1"', '')
.option('-t, --tag', 'also tag the commit')
.option('-d, --debug', 'useful if you face any error; outputs full error stack trace')
.parse(process.argv);
const options = {
directory: process.cwd(),
force: program.force,
tag: program.tag,
noVerify: !program.verify,
overrideVersion: program.override,
postfix: program.postfix
};
commitRelease(options)
.then(onSuccess)
.catch(onError);
function onSuccess({version, tag}) {
c.log(
chalk.green(
`Release ${version} committed${(tag ? ' and tagged' : '')}; changelog updated.`
)
);
}
function onError(err) {
c.error(chalk.red(err.message ? err.message : err));
if (program.debug) {
c.error(err.stack);
}
process.exit(1);
}