Nuxt/bin/nuxt
2018-03-12 02:44:46 +03:30

36 lines
742 B
JavaScript
Executable File

#!/usr/bin/env node
const { join } = require('path')
const semver = require('semver')
const { Utils } = require('..')
const { name, engines } = require('../package.json')
// 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)