forked from adonisjs/adonis-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·41 lines (36 loc) · 1019 Bytes
/
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
'use strict'
/*
* adonis-cli
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
const path = require('path')
const Commands = require('./src/Commands')
const commandNames = []
const needProviders = ['repl', 'route:list', 'run:instructions']
const ace = require('./lib/ace')
// register internal commands
Object.keys(Commands).forEach((name) => {
commandNames.push(name)
ace.addCommand(Commands[name])
})
// require user project .ace file
try {
const command = process.argv[2]
if (commandNames.indexOf(command) > -1 && needProviders.indexOf(command) <= -1) {
ace.wireUpWithCommander()
ace.invoke(require('./package'))
} else {
require(path.join(process.cwd(), 'ace'))
}
} catch (error) {
if (error.code !== 'ENOENT' && error.code !== 'MODULE_NOT_FOUND') {
throw error
}
ace.wireUpWithCommander()
ace.invoke(require('./package'))
}