-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·41 lines (35 loc) · 1.54 KB
/
index.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
#!/usr/bin/env node
const program = require('commander');
require('colors');
const utils = require('./src/utils/');
const create = require('./src/create');
program
.version(require('./package.json').version)
.option('-e, --entry <filename>', 'Entry point/points to build your project', value => value.split(','))
.option('-o, --output <filename>', 'The output filename path')
.option('-c, --context [directory]', 'The base directory')
.option('-d, --devtool [style]', 'Enhance the debugging process by adding source maps')
.option('-l, --loaders [loaders]', 'Add loaders', value => value.split(','))
.option('-s, --devserver', 'Add webpack-dev-server')
.option('-w, --watch', 'Watch files and recompile whenever they change')
.option('-a, --autoinstall', 'Automatically install required dependencies')
.parse(process.argv);
if (!program.entry) {
utils.log.error('Entry cannot be empty');
process.exit(0);
} else if (!program.output) {
utils.log.error('Output path cannot be empty');
process.exit(0);
} else if (program.devtool && !utils.validDevTool(program.devtool)) {
utils.log.error(`Devtool "${program.devtool}" does not exist!`);
process.exit(0);
} else if (program.loaders) {
//loop through each provided loader to display which loader is missing
for (let loader of program.loaders) {
if (!utils.getLoaders(loader)) { //if the loader is not available
utils.log.error(`Loader "${loader}" does not exist!`);
process.exit(0);
}
}
}
create(program);