2016-11-08 00:18:26 +00:00
|
|
|
#!/usr/bin/env node
|
2018-01-16 06:43:41 +00:00
|
|
|
|
2018-01-11 14:11:49 +00:00
|
|
|
const { join } = require('path')
|
2018-01-30 01:57:24 +00:00
|
|
|
const semver = require('semver')
|
2018-02-07 00:26:40 +00:00
|
|
|
|
2018-01-13 05:10:01 +00:00
|
|
|
const { Utils } = require('..')
|
2018-02-07 00:26:40 +00:00
|
|
|
const { name, engines } = require('../package.json')
|
2016-11-07 01:34:58 +00:00
|
|
|
|
2018-01-11 14:11:49 +00:00
|
|
|
// Global error handler
|
|
|
|
process.on('unhandledRejection', _error => {
|
2018-01-13 05:10:01 +00:00
|
|
|
Utils.printError(_error)
|
2018-01-11 14:11:49 +00:00
|
|
|
})
|
2016-11-07 01:34:58 +00:00
|
|
|
|
2018-01-30 01:57:24 +00:00
|
|
|
if (!semver.satisfies(process.version, engines.node)) {
|
2018-02-07 00:26:40 +00:00
|
|
|
Utils.fatalError(
|
|
|
|
`The engine "node" is incompatible with ${name}. Expected version "${
|
|
|
|
engines.node
|
|
|
|
}".`
|
|
|
|
)
|
2018-01-30 01:57:24 +00:00
|
|
|
}
|
|
|
|
|
2017-06-16 12:42:45 +00:00
|
|
|
const defaultCommand = 'dev'
|
2018-01-11 14:11:49 +00:00
|
|
|
const commands = new Set([defaultCommand, 'init', 'build', 'start', 'generate'])
|
2016-11-07 01:34:58 +00:00
|
|
|
|
2016-12-09 18:40:59 +00:00
|
|
|
var cmd = process.argv[2]
|
2016-11-07 01:34:58 +00:00
|
|
|
|
|
|
|
if (commands.has(cmd)) {
|
2017-01-20 11:43:48 +00:00
|
|
|
process.argv.splice(2, 1)
|
2016-11-07 01:34:58 +00:00
|
|
|
} else {
|
|
|
|
cmd = defaultCommand
|
|
|
|
}
|
|
|
|
|
2017-06-16 12:42:45 +00:00
|
|
|
const bin = join(__dirname, 'nuxt-' + cmd)
|
2016-11-07 01:34:58 +00:00
|
|
|
|
2017-01-20 11:43:48 +00:00
|
|
|
require(bin)
|