Support truthy T3_NO_OPEN environment values
Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
1 parent
53b815b194
commit
74a5c87bac
2 files changed
+32
-1
No files matched your search
@@ -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(
|
||||
[
|
||||
|
||||
+10
-1
@@ -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;
|
||||
|
||||
|
||||
Reference in new issue
Block a user