-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
cli.js
executable file
·50 lines (39 loc) · 859 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
'use strict';
const figures = require('figures');
const chalk = require('chalk');
const meow = require('meow');
const main = require('./lib/main');
const {STATE_ERROR} = require('./lib/states');
meow({
help: `
Usage: trevor [options]
Options:
-h, --help Show this help
Required files (in the current directory):
- package.json
- .travis.yml
`
}, {
alias: {h: 'help'}
});
const cwd = process.cwd();
main({cwd})
.then(state => {
let hasErrors = false;
for (const currentState of state.values()) {
if (currentState === STATE_ERROR) {
hasErrors = true;
break;
}
}
process.exit(hasErrors ? 1 : 0);
})
.catch(err => {
if (err.name === 'TrevorError') {
console.log(`\n ${chalk.red(figures.cross)} ${err.message}\n`);
} else {
console.log(err.stack);
}
process.exit(1);
});