pretty-error integration

This commit is contained in:
Pooya Parsa 2017-08-05 22:16:39 +04:30
parent 5d0681088d
commit ea33d83c2e
6 changed files with 26 additions and 9 deletions

View File

@ -1,6 +1,7 @@
#!/usr/bin/env node #!/usr/bin/env node
const join = require('path').join const join = require('path').join
require('../lib/common/errors')
const defaultCommand = 'dev' const defaultCommand = 'dev'
const commands = new Set([ const commands = new Set([
@ -21,11 +22,4 @@ if (commands.has(cmd)) {
const bin = join(__dirname, 'nuxt-' + cmd) 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) require(bin)

View File

@ -14,7 +14,8 @@ const packageJSON = readJSONSync(resolve(rootDir, 'package.json'))
// Required and Excluded packages for start // Required and Excluded packages for start
let requires = [ let requires = [
'source-map-support' 'source-map-support',
'pretty-error'
] ]
const excludes = [ const excludes = [

20
lib/common/errors.js Normal file
View File

@ -0,0 +1,20 @@
const PrettyError = require('pretty-error')
// Start default instance
const pe = PrettyError.start()
// Configure prettyError instance
pe.skipPackage('regenerator-runtime')
pe.skipPackage('babel-runtime')
pe.skipPackage('core-js')
pe.skipNodeFiles()
// Console error unhandled promises
process.on('unhandledRejection', function (err) {
/* eslint-disable no-console */
console.log(pe.render(err))
})
module.exports = {
pe
}

View File

@ -97,6 +97,7 @@
"minimist": "^1.2.0", "minimist": "^1.2.0",
"opencollective": "^1.0.3", "opencollective": "^1.0.3",
"pify": "^3.0.0", "pify": "^3.0.0",
"pretty-error": "^2.1.1",
"progress-bar-webpack-plugin": "^1.10.0", "progress-bar-webpack-plugin": "^1.10.0",
"serialize-javascript": "^1.4.0", "serialize-javascript": "^1.4.0",
"serve-static": "^1.12.3", "serve-static": "^1.12.3",

View File

@ -48,6 +48,7 @@
}, },
"dependencies": { "dependencies": {
"source-map-support": "^0.4.15", "source-map-support": "^0.4.15",
"pretty-error": "^2.1.1",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"hash-sum": "^1.0.2", "hash-sum": "^1.0.2",
"tappable": "^1.1.0", "tappable": "^1.1.0",

View File

@ -4944,7 +4944,7 @@ preserve@^0.2.0:
version "0.2.0" version "0.2.0"
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
pretty-error@^2.0.2: pretty-error@^2.0.2, pretty-error@^2.1.1:
version "2.1.1" version "2.1.1"
resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-2.1.1.tgz#5f4f87c8f91e5ae3f3ba87ab4cf5e03b1a17f1a3" resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-2.1.1.tgz#5f4f87c8f91e5ae3f3ba87ab4cf5e03b1a17f1a3"
dependencies: dependencies: