mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-18 19:55:12 +00:00
34 lines
588 B
JavaScript
34 lines
588 B
JavaScript
import consola from 'consola'
|
|
import * as commands from './commands'
|
|
import setup from './setup'
|
|
|
|
export default function run() {
|
|
const defaultCommand = 'dev'
|
|
|
|
const cmds = new Set([
|
|
defaultCommand,
|
|
'build',
|
|
'start',
|
|
'generate'
|
|
])
|
|
|
|
let cmd = process.argv[2]
|
|
|
|
if (cmds.has(cmd)) {
|
|
process.argv.splice(2, 1)
|
|
} else {
|
|
cmd = defaultCommand
|
|
}
|
|
|
|
// Setup runtime
|
|
setup({
|
|
dev: cmd === 'dev'
|
|
})
|
|
|
|
return commands[cmd]() // eslint-disable-line import/namespace
|
|
.then(m => m.default())
|
|
.catch((error) => {
|
|
consola.fatal(error)
|
|
})
|
|
}
|