File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -4,12 +4,17 @@ import { cli } from "./cli";
44import { checkAutoUpdate } from "./commands/update.js" ;
55import { installTelemetry , flushTelemetry } from "./telemetry.js" ;
66import { handleCliError } from "./errors.js" ;
7+ import { getOutputFormat } from "./output.js" ;
78
89installTelemetry ( cli ) ;
910
1011function resolveOutputFormat ( ) : "tui" | "json" {
11- const opts = cli . optsWithGlobals ?. ( ) ;
12- if ( opts ?. output === "tui" || opts ?. output === "json" ) return opts . output ;
12+ try {
13+ return getOutputFormat ( cli ) ;
14+ } catch {
15+ // Fallback for unexpected failures before Commander parses options.
16+ return process . stderr . isTTY ? "tui" : "json" ;
17+ }
1318 return process . stderr . isTTY ? "tui" : "json" ;
1419}
1520
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ describe("handleCliError", () => {
99 beforeEach ( ( ) => {
1010 originalIsTTY = process . stderr . isTTY ;
1111 exitSpy = spyOn ( process , "exit" ) . mockImplementation ( ( code ?: number ) => {
12- throw new Error ( `exit:${ code } ` ) ;
12+ throw new Error ( `exit:${ code ?? 0 } ` ) ;
1313 } ) ;
1414 errorSpy = spyOn ( console , "error" ) . mockImplementation ( ( ) => { } ) ;
1515 } ) ;
You can’t perform that action at this time.
0 commit comments