Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fcc8086

Browse files
committedApr 12, 2022
feat: add CS_DISABLE_FILE_DOWNLOADS
1 parent 4ce0ad8 commit fcc8086

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
 

‎src/node/cli.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,10 @@ export async function setDefaults(cliArgs: UserProvidedArgs, configArgs?: Config
542542
args.password = process.env.PASSWORD
543543
}
544544

545+
if (process.env.CS_DISABLE_FILE_DOWNLOADS) {
546+
args["disable-file-downloads"] = true
547+
}
548+
545549
const usingEnvHashedPassword = !!process.env.HASHED_PASSWORD
546550
if (process.env.HASHED_PASSWORD) {
547551
args["hashed-password"] = process.env.HASHED_PASSWORD
@@ -556,6 +560,7 @@ export async function setDefaults(cliArgs: UserProvidedArgs, configArgs?: Config
556560
delete process.env.PASSWORD
557561
delete process.env.HASHED_PASSWORD
558562
delete process.env.GITHUB_TOKEN
563+
delete process.env.CS_DISABLE_FILE_DOWNLOADS
559564

560565
// Filter duplicate proxy domains and remove any leading `*.`.
561566
const proxyDomains = new Set((args["proxy-domain"] || []).map((d) => d.replace(/^\*\./, "")))

‎test/unit/node/cli.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,18 @@ describe("parser", () => {
349349
expect(process.env.GITHUB_TOKEN).toBe(undefined)
350350
})
351351

352+
it("should use env var CS_DISABLE_FILE_DOWNLOADS", async () => {
353+
process.env.CS_DISABLE_FILE_DOWNLOADS = "0"
354+
const args = parse([])
355+
expect(args).toEqual({})
356+
357+
const defaultArgs = await setDefaults(args)
358+
expect(defaultArgs).toEqual({
359+
...defaults,
360+
"disable-file-downloads": true,
361+
})
362+
})
363+
352364
it("should error if password passed in", () => {
353365
expect(() => parse(["--password", "supersecret123"])).toThrowError(
354366
"--password can only be set in the config file or passed in via $PASSWORD",

0 commit comments

Comments
 (0)
Please sign in to comment.