diff --git a/apps/t3/src/cli.test.ts b/apps/t3/src/cli.test.ts index 3a7c14c9c2..3d3b38580f 100644 --- a/apps/t3/src/cli.test.ts +++ b/apps/t3/src/cli.test.ts @@ -237,12 +237,24 @@ describe("parseCliOptions", () => { ); }); + it("rejects negative backend port values provided as separate args", () => { + expect(() => parseCliOptions(["--backend-port", "-1"], {}, "/workspace")).toThrow( + "Invalid value for --backend-port", + ); + }); + it("throws when web port value is missing", () => { expect(() => parseCliOptions(["--web-port"], {}, "/workspace")).toThrow( "Missing value for --web-port", ); }); + it("rejects negative web port values provided as separate args", () => { + expect(() => parseCliOptions(["--web-port", "-1"], {}, "/workspace")).toThrow( + "Invalid value for --web-port", + ); + }); + it("throws for invalid environment port values", () => { expect(() => parseCliOptions([], { T3_WEB_PORT: "nope" }, "/workspace")).toThrow( "Invalid value for T3_WEB_PORT", diff --git a/apps/t3/src/cli.ts b/apps/t3/src/cli.ts index a11eb1d22e..dc2198fa11 100644 --- a/apps/t3/src/cli.ts +++ b/apps/t3/src/cli.ts @@ -198,7 +198,7 @@ export function parseCliOptions( if (arg === "--backend-port") { backendPort = parseExplicitPort( - readArgValue(argv, index, "--backend-port"), + readArgValue(argv, index, "--backend-port", { allowDashPrefixed: true }), "--backend-port", ); backendPortLocked = true; @@ -213,7 +213,10 @@ export function parseCliOptions( } if (arg === "--web-port") { - webPort = parseExplicitPort(readArgValue(argv, index, "--web-port"), "--web-port"); + webPort = parseExplicitPort( + readArgValue(argv, index, "--web-port", { allowDashPrefixed: true }), + "--web-port", + ); webPortLocked = true; index += 1; continue;