-
Notifications
You must be signed in to change notification settings - Fork 4
/
raptor
executable file
·42 lines (33 loc) · 1.04 KB
/
raptor
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
#! /usr/bin/env node
'use strict';
let cosmic = require('cosmiconfig');
let debug = require('debug')('raptor:cli');
let pkg = require('./package.json');
let R = require('ramda');
let Vorpal = require('vorpal');
const MODULE = 'raptor';
let cli = new Vorpal();
let extend = (plugins, config) => {
return Promise.all(R.map(plugin => {
return Promise
.resolve(require(plugin)(cli))
.then(command => {
if (!command) {
return;
}
try {
debug(`Loading plugin ${plugin}@${require(`${plugin}/package.json`).version}`);
} finally {
R.map(R.apply((key, value) => command[key] = value), R.toPairs(config[command._name]));
}
});
}, plugins));
};
let parse = () => cli.parse(process.argv);
process.on('SIGINT', () => process.exit(2));
debug(`Using @mozilla/raptor@${pkg.version}`);
cosmic(MODULE, pkg.config.cosmic)
.then(base => base ? base.config : {})
.then(config => extend(pkg.config.cli.plugins, config))
.then(parse)
.catch(err => console.error(err.stack));