mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
33 lines
643 B
JavaScript
Executable File
33 lines
643 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
const { join } = require('path')
|
|
|
|
const consola = require('consola')
|
|
|
|
// Global error handler
|
|
process.on('unhandledRejection', err => consola.error(err))
|
|
|
|
// Exit process on fatal errors
|
|
consola.add({
|
|
log(logObj) {
|
|
if (logObj.type === 'fatal') {
|
|
process.stderr.write('Nuxt Fatal Error :(\n')
|
|
process.exit(1)
|
|
}
|
|
}
|
|
})
|
|
|
|
const defaultCommand = 'dev'
|
|
const commands = new Set([defaultCommand, 'init', 'build', 'start', 'generate'])
|
|
|
|
let cmd = process.argv[2]
|
|
|
|
if (commands.has(cmd)) {
|
|
process.argv.splice(2, 1)
|
|
} else {
|
|
cmd = defaultCommand
|
|
}
|
|
|
|
const bin = join(__dirname, 'nuxt-' + cmd)
|
|
|
|
require(bin)
|