diff --git a/apps/t3/src/cli.test.ts b/apps/t3/src/cli.test.ts index 53b773edec..b23c83fb0f 100644 --- a/apps/t3/src/cli.test.ts +++ b/apps/t3/src/cli.test.ts @@ -25,6 +25,28 @@ describe("parseCliOptions", () => { expect(options.webPortLocked).toBe(true); }); + it("accepts flexible truthy values for T3_NO_OPEN", () => { + const options = parseCliOptions( + [], + { + T3_NO_OPEN: "true", + }, + "/workspace", + ); + expect(options.noOpen).toBe(true); + }); + + it("treats non-truthy T3_NO_OPEN values as disabled", () => { + const options = parseCliOptions( + [], + { + T3_NO_OPEN: "0", + }, + "/workspace", + ); + expect(options.noOpen).toBe(false); + }); + it("allows command line arguments to override defaults", () => { const options = parseCliOptions( [ diff --git a/apps/t3/src/cli.ts b/apps/t3/src/cli.ts index 340a59b310..2fd52a1efc 100644 --- a/apps/t3/src/cli.ts +++ b/apps/t3/src/cli.ts @@ -45,6 +45,15 @@ function parseExplicitPath(value: string, key: string): string { return path.resolve(trimmed); } +function parseBooleanEnvFlag(value: string | undefined): boolean { + if (!value) { + return false; + } + + const normalized = value.trim().toLowerCase(); + return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on"; +} + interface CliOptions { backendPort: number; webPort: number; @@ -108,7 +117,7 @@ export function parseCliOptions( let webPortLocked = webPortFromEnv.locked; let launchCwd = cwd; let usedPositionalCwd = false; - let noOpen = env.T3_NO_OPEN === "1"; + let noOpen = parseBooleanEnvFlag(env.T3_NO_OPEN); let showHelp = false; let showVersion = false;