mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 17:37:14 +00:00
44 lines
922 B
JavaScript
Executable File
44 lines
922 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
const { join } = require('path')
|
|
const semver = require('semver')
|
|
const consola = require('consola')
|
|
const { name, engines } = require('../package.json')
|
|
|
|
// Global error handler
|
|
process.on('unhandledRejection', _error => {
|
|
consola.error(_error)
|
|
})
|
|
|
|
// Exit process on fatal errors
|
|
consola.add({
|
|
log(logObj) {
|
|
if (logObj.type === 'fatal') {
|
|
process.stderr.write('Nuxt Fatal Error :(\n')
|
|
process.exit(1)
|
|
}
|
|
}
|
|
})
|
|
|
|
if (!semver.satisfies(process.version, engines.node)) {
|
|
consola.fatal(
|
|
`The engine "node" is incompatible with ${name}. Expected version "${
|
|
engines.node
|
|
}".`
|
|
)
|
|
}
|
|
|
|
const defaultCommand = 'dev'
|
|
const commands = new Set([defaultCommand, 'init', 'build', 'start', 'generate'])
|
|
|
|
var cmd = process.argv[2]
|
|
|
|
if (commands.has(cmd)) {
|
|
process.argv.splice(2, 1)
|
|
} else {
|
|
cmd = defaultCommand
|
|
}
|
|
|
|
const bin = join(__dirname, 'nuxt-' + cmd)
|
|
|
|
require(bin)
|