mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-14 10:04:05 +00:00
34 lines
785 B
JavaScript
Executable File
34 lines
785 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
// Show logs
|
|
process.env.DEBUG = process.env.DEBUG || 'nuxt:*'
|
|
|
|
const { join } = require('path')
|
|
const { name, engines } = require('../package.json')
|
|
const semver = require('semver')
|
|
const { Utils } = require('..')
|
|
|
|
// Global error handler
|
|
process.on('unhandledRejection', _error => {
|
|
Utils.printError(_error)
|
|
})
|
|
|
|
if (!semver.satisfies(process.version, engines.node)) {
|
|
Utils.fatalError(`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)
|