Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
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') {
const errorMessage = String(logObj.args[0])
process.stderr.write(fatalBox(errorMessage))
exit(1)
}
}
})
// Wrap all console logs with consola for better DX
consola.wrapConsole()
}
useSSRLog () {
if (!this.options.render.ssrLog) {
return
}
const logs = []
const devReporter = {
log (logObj) {
logs.push({
...logObj,
args: logObj.args.map(arg => format(arg))
})
}
}
consola.addReporter(devReporter)
return () => {
consola.removeReporter(devReporter)
return logs
}
}