diff options
Diffstat (limited to 'packages/cli/src/ui/utils/ConsolePatcher.ts')
| -rw-r--r-- | packages/cli/src/ui/utils/ConsolePatcher.ts | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/packages/cli/src/ui/utils/ConsolePatcher.ts b/packages/cli/src/ui/utils/ConsolePatcher.ts index 10be3bc7..a429698d 100644 --- a/packages/cli/src/ui/utils/ConsolePatcher.ts +++ b/packages/cli/src/ui/utils/ConsolePatcher.ts @@ -8,8 +8,9 @@ import util from 'util'; import { ConsoleMessageItem } from '../types.js'; interface ConsolePatcherParams { - onNewMessage: (message: Omit<ConsoleMessageItem, 'id'>) => void; + onNewMessage?: (message: Omit<ConsoleMessageItem, 'id'>) => void; debugMode: boolean; + stderr?: boolean; } export class ConsolePatcher { @@ -46,16 +47,22 @@ export class ConsolePatcher { originalMethod: (...args: unknown[]) => void, ) => (...args: unknown[]) => { - if (this.params.debugMode) { - originalMethod.apply(console, args); - } + if (this.params.stderr) { + if (type !== 'debug' || this.params.debugMode) { + this.originalConsoleError(this.formatArgs(args)); + } + } else { + if (this.params.debugMode) { + originalMethod.apply(console, args); + } - if (type !== 'debug' || this.params.debugMode) { - this.params.onNewMessage({ - type, - content: this.formatArgs(args), - count: 1, - }); + if (type !== 'debug' || this.params.debugMode) { + this.params.onNewMessage?.({ + type, + content: this.formatArgs(args), + count: 1, + }); + } } }; } |
