From e3c8bd692ce00cee1108f6143f55af66430ce8e1 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 26 Apr 2022 15:09:53 -0500 Subject: [PATCH] feat(cli): support true for CS_DISABLE_FILE_DOWNLOADS (#5134) After some feedback, we realized it is more intuitive to disable file downloads by setting the environment variable `CS_DISABLE_FILE_DOWNLOADS` to `true` than `1`. This commit adds support for both. --- src/node/cli.ts | 2 +- test/unit/node/cli.test.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/node/cli.ts b/src/node/cli.ts index 2522a6268..6c33060cd 100644 --- a/src/node/cli.ts +++ b/src/node/cli.ts @@ -542,7 +542,7 @@ export async function setDefaults(cliArgs: UserProvidedArgs, configArgs?: Config args.password = process.env.PASSWORD } - if (process.env.CS_DISABLE_FILE_DOWNLOADS === "1") { + if (process.env.CS_DISABLE_FILE_DOWNLOADS?.match(/^(1|true)$/)) { args["disable-file-downloads"] = true } diff --git a/test/unit/node/cli.test.ts b/test/unit/node/cli.test.ts index dab47b4cf..76ebb610f 100644 --- a/test/unit/node/cli.test.ts +++ b/test/unit/node/cli.test.ts @@ -362,6 +362,18 @@ describe("parser", () => { }) }) + it("should use env var CS_DISABLE_FILE_DOWNLOADS set to true", async () => { + process.env.CS_DISABLE_FILE_DOWNLOADS = "true" + const args = parse([]) + expect(args).toEqual({}) + + const defaultArgs = await setDefaults(args) + expect(defaultArgs).toEqual({ + ...defaults, + "disable-file-downloads": true, + }) + }) + it("should error if password passed in", () => { expect(() => parse(["--password", "supersecret123"])).toThrowError( "--password can only be set in the config file or passed in via $PASSWORD",