mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-18 03:35:17 +00:00
1dd32d0d21
* add ~> addReporter * remove badge * withScope ~> withTag * update to consola 2 * update build tests
33 lines
653 B
JavaScript
33 lines
653 B
JavaScript
import consola from 'consola'
|
|
|
|
let _setup = false
|
|
|
|
export default function setup({ dev }) {
|
|
// Apply default NODE_ENV if not provided
|
|
if (!process.env.NODE_ENV) {
|
|
process.env.NODE_ENV = dev ? 'development' : 'production'
|
|
}
|
|
|
|
if (_setup) {
|
|
return
|
|
}
|
|
_setup = true
|
|
|
|
// Global error handler
|
|
/* istanbul ignore next */
|
|
process.on('unhandledRejection', (err) => {
|
|
consola.error(err)
|
|
})
|
|
|
|
// Exit process on fatal errors
|
|
/* istanbul ignore next */
|
|
consola.addReporter({
|
|
log(logObj) {
|
|
if (logObj.type === 'fatal') {
|
|
process.stderr.write('Nuxt Fatal Error :(\n')
|
|
process.exit(1)
|
|
}
|
|
}
|
|
})
|
|
}
|