feat: Add --debug flag for printing debug logs for all CLI commands (#75)

This commit is contained in:
Aaron
2023-08-13 14:04:43 -05:00
committed by GitHub
parent e164bd51fe
commit d05f126eb3
13 changed files with 43 additions and 5 deletions
+8 -1
View File
@@ -1,4 +1,4 @@
import { consola } from 'consola';
import { LogLevels, consola } from 'consola';
import { printHeader } from '../../core/log/printHeader';
import { formatDuration } from '../../core/utils/formatDuration';
@@ -9,6 +9,13 @@ export function defineCommand<TArgs extends any[]>(
},
) {
return async (...args: TArgs) => {
// Enable consola's debug mode globally at the start of all commands when the `--debug` flag is
// passed
const isDebug = !!args.find((arg) => arg?.debug);
if (isDebug) {
consola.level = LogLevels.debug;
}
const startTime = Date.now();
try {
printHeader();