1 | #!/usr/bin/env node
|
2 | let flags = require('minimist')(process.argv.slice(2));
|
3 | let command = flags._[0];
|
4 |
|
5 | if (['release', 'init', 'help', 'build', 'devServer', 'test', 'analyze'].indexOf(command) === -1) {
|
6 | console.log('JARB: invalid command!, please select one of... [\'init\',\'analyze\', \'help\', \'build\', \'devServer\', \'test\', \'analyze\']');
|
7 | }
|
8 |
|
9 | if (!flags.env) {
|
10 | flags.env = 'production';
|
11 | }
|
12 |
|
13 | process.env.JARB_FLAGS = JSON.stringify(flags);
|
14 |
|
15 | if (command === 'init') {
|
16 | require('./init');
|
17 | }
|
18 |
|
19 | if (command === 'build') {
|
20 | if (flags.env === 'production') {
|
21 | process.env.REACT_WEBPACK_ENV = 'production';
|
22 | process.env.NODE_ENV = 'production';
|
23 | } else if (flags.env === 'staging') {
|
24 | process.env.NODE_ENV = 'staging';
|
25 | }
|
26 | require('./build');
|
27 | }
|
28 |
|
29 | if (command === 'devServer') {
|
30 | process.env.NODE_ENV = 'develop';
|
31 | process.env.REACT_WEBPACK_ENV = 'develop';
|
32 | require('./devServer');
|
33 | }
|
34 |
|
35 | if (command === 'test') {
|
36 | require('./test');
|
37 | }
|
38 |
|
39 | if (command === 'release') {
|
40 | require('./release');
|
41 | }
|
42 |
|
43 | if (command === 'analyze') {
|
44 | process.env.NODE_ENV = 'production';
|
45 | require('./analyze');
|
46 | } |
\ | No newline at end of file |