Nuxt/bin/nuxt

33 lines
637 B
Plaintext
Raw Normal View History

2016-11-08 00:18:26 +00:00
#!/usr/bin/env node
2016-11-07 01:34:58 +00:00
2016-12-09 18:40:59 +00:00
var join = require('path').join
var spawn = require('cross-spawn').spawn
2016-11-07 01:34:58 +00:00
2016-12-09 18:40:59 +00:00
var defaultCommand = 'dev'
var commands = new Set([
2016-11-07 01:34:58 +00:00
defaultCommand,
'init',
'build',
2016-11-10 11:33:52 +00:00
'start',
'generate'
2016-11-07 01:34:58 +00:00
])
2016-12-09 18:40:59 +00:00
var cmd = process.argv[2]
var args
2016-11-07 01:34:58 +00:00
if (commands.has(cmd)) {
args = process.argv.slice(3)
} else {
cmd = defaultCommand
args = process.argv.slice(2)
}
2016-12-09 18:40:59 +00:00
var bin = join(__dirname, 'nuxt-' + cmd)
2016-11-07 01:34:58 +00:00
2016-12-09 18:40:59 +00:00
var proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] })
2016-11-07 01:34:58 +00:00
proc.on('close', (code) => process.exit(code))
proc.on('error', (err) => {
2016-12-09 17:54:41 +00:00
console.error(err) // eslint-disable-line no-console
2016-11-07 01:34:58 +00:00
process.exit(1)
})