Skip to content

Commit

Permalink
feat(cli): support true for CS_DISABLE_FILE_DOWNLOADS (#5134)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jsjoeio committed Apr 26, 2022
1 parent a0b3614 commit e3c8bd6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
12 changes: 12 additions & 0 deletions test/unit/node/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit e3c8bd6

Please sign in to comment.