UNPKG

1.1 kBJavaScriptView Raw
1#!/usr/bin/env node
2let flags = require('minimist')(process.argv.slice(2));
3let command = flags._[0];
4
5if (['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
9if (!flags.env) {
10 flags.env = 'production';
11}
12
13process.env.JARB_FLAGS = JSON.stringify(flags);
14
15if (command === 'init') {
16 require('./init');
17}
18
19if (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
29if (command === 'devServer') {
30 process.env.NODE_ENV = 'develop';
31 process.env.REACT_WEBPACK_ENV = 'develop';
32 require('./devServer');
33}
34
35if (command === 'test') {
36 require('./test');
37}
38
39if (command === 'release') {
40 require('./release');
41}
42
43if (command === 'analyze') {
44 process.env.NODE_ENV = 'production';
45 require('./analyze');
46}
\No newline at end of file