UNPKG

1.18 kBPlain TextView Raw
1#!/usr/bin/env node
2
3const localFile = require('import-local-file')(__filename)
4if (localFile) {
5 require(localFile)
6}
7else {
8 require('../lib/node-version-check')
9 require('../lib/helpers/cli-error-handling')
10
11 const commands = [
12 'init',
13 'dev',
14 'build',
15 'clean',
16 'mode',
17 'info',
18 'serve',
19 'new',
20 'help'
21 ]
22
23 let cmd = process.argv[2]
24
25 if (cmd) {
26 if (cmd.length === 1) {
27 const mapToCmd = {
28 d: 'dev',
29 b: 'build',
30 c: 'clean',
31 m: 'mode',
32 i: 'info',
33 s: 'serve',
34 n: 'new',
35 h: 'help'
36 }
37 cmd = mapToCmd[cmd]
38 }
39
40 if (commands.includes(cmd)) {
41 process.argv.splice(2, 1)
42 }
43 else {
44 if (cmd === '-v' || cmd === '--version') {
45 console.log(require('../package.json').version)
46 process.exit(0)
47 }
48
49 const warn = require('../lib/helpers/logger')('app', 'red')
50
51 warn()
52 warn(`Unknown command "${ cmd }"`)
53 if (cmd.indexOf('-') === 0) {
54 warn(`Command must come before the options`)
55 }
56
57 warn()
58 cmd = 'help'
59 }
60 }
61 else {
62 cmd = 'help'
63 }
64
65 require(`./quasar-${cmd}`)
66}