1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | import 'babel-polyfill';
|
9 |
|
10 |
|
11 | import { resolve } from 'path';
|
12 |
|
13 |
|
14 | const defaultCommand = 'collective';
|
15 |
|
16 | const commands = new Set([
|
17 | 'help',
|
18 | 'info',
|
19 | 'stats',
|
20 | 'list',
|
21 | 'donate',
|
22 | 'ls',
|
23 | 'rm',
|
24 | 'remove',
|
25 | 'cc',
|
26 | 'billing',
|
27 | 'show',
|
28 | 'open',
|
29 | 'postinstall',
|
30 | 'setup',
|
31 | 'slack',
|
32 | 'support',
|
33 | 'email',
|
34 | 'twitter'
|
35 | ]);
|
36 |
|
37 | const aliases = new Map([
|
38 | ['ls', 'list'],
|
39 | ['rm', 'remove'],
|
40 | ['cc', 'billing'],
|
41 | ['info', 'collective'],
|
42 | ['stats', 'collective']
|
43 | ]);
|
44 |
|
45 | let cmd = defaultCommand;
|
46 | const args = process.argv.slice(2);
|
47 | const index = args.findIndex(a => commands.has(a));
|
48 |
|
49 | if (index > -1) {
|
50 | cmd = args[index];
|
51 | args.splice(index, 1);
|
52 |
|
53 | if (cmd === 'help') {
|
54 | if (index < args.length && commands.has(args[index])) {
|
55 | cmd = args[index];
|
56 | args.splice(index, 1);
|
57 | } else {
|
58 | cmd = defaultCommand;
|
59 | }
|
60 |
|
61 | args.unshift('--help');
|
62 | }
|
63 |
|
64 | cmd = aliases.get(cmd) || cmd;
|
65 | }
|
66 |
|
67 | const bin = resolve(__dirname, '../commands/', cmd + '.js');
|
68 |
|
69 |
|
70 | process.argv = process.argv.slice(0, 2).concat(args);
|
71 |
|
72 |
|
73 |
|
74 | require(bin, 'may-exclude');
|