|
1 | 1 | import mri from 'mri'
|
2 | 2 | import { red } from 'colorette'
|
3 |
| -import consola from 'consola' |
| 3 | +import consola, { ConsolaReporter } from 'consola' |
4 | 4 | import { checkEngines } from './utils/engines'
|
5 | 5 | import { commands, Command, NuxtCommand } from './commands'
|
6 | 6 | import { showHelp } from './utils/help'
|
@@ -39,7 +39,29 @@ async function _main () {
|
39 | 39 | }
|
40 | 40 |
|
41 | 41 | // Wrap all console logs with consola for better DX
|
42 |
| -consola.wrapConsole() |
| 42 | +consola.wrapAll() |
| 43 | + |
| 44 | +// Filter out unwanted logs |
| 45 | +// TODO: Use better API from consola for intercepting logs |
| 46 | +const wrapReporter = (reporter: ConsolaReporter) => <ConsolaReporter> { |
| 47 | + log (logObj, ctx) { |
| 48 | + if (!logObj.args || !logObj.args.length) { return } |
| 49 | + const msg = logObj.args[0] |
| 50 | + if (typeof msg === 'string' && !process.env.DEBUG) { |
| 51 | + // Hide vue-router 404 warnings |
| 52 | + if (msg.startsWith('[Vue Router warn]: No match found for location with path')) { |
| 53 | + return |
| 54 | + } |
| 55 | + // Hide sourcemap warnings related to node_modules |
| 56 | + if (msg.startsWith('Sourcemap') && msg.includes('node_modules')) { |
| 57 | + return |
| 58 | + } |
| 59 | + } |
| 60 | + return reporter.log(logObj, ctx) |
| 61 | + } |
| 62 | +} |
| 63 | +// @ts-expect-error |
| 64 | +consola._reporters = consola._reporters.map(wrapReporter) |
43 | 65 |
|
44 | 66 | process.on('unhandledRejection', err => consola.error('[unhandledRejection]', err))
|
45 | 67 | process.on('uncaughtException', err => consola.error('[uncaughtException]', err))
|
|
0 commit comments