Nuxt/bin/nuxt
Pooya Parsa 85825d190c fix: gracefully handle unhandled promises
This prevents nuxt process exiting in dev mode on unhandled promises
2017-07-09 17:07:54 +04:30

36 lines
678 B
JavaScript
Executable File

#!/usr/bin/env node
// Node Source Map Support
// https://github.com/evanw/node-source-map-support
require('source-map-support').install()
const join = require('path').join
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)
// Console error unhandled promises
process.on('unhandledRejection', function (err) {
/* eslint-disable no-console */
console.error(err)
console.error('[nuxt] Unhandled promise rejection: ' + err)
})
require(bin)