UNPKG

721 BJavaScriptView Raw
1#!/usr/bin/env node
2
3const { compiler } = require('./dist/common.js')
4const args = process.argv.slice(2)
5
6const commands = [
7 'development',
8 'production',
9 'debug',
10]
11
12// Find the first right command
13const scriptIndex = args.findIndex(
14 x => commands.includes(x)
15)
16
17// The right command or the first one...
18const script = scriptIndex === -1 ? args[0] : args[scriptIndex]
19
20switch (script) {
21 case 'development':
22 compiler('development')
23 break
24 case 'production':
25 compiler('production')
26 break
27 case 'debug':
28 compiler('debug')
29 break
30 default:
31 console.log('Unknown command "' + script + '"')
32 console.log('Available commands are:')
33 commands.map(c => { console.log(c) })
34 break
35}