Skip to content

Commit

Permalink
feat(cli): add disable-file-downloads to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
jsjoeio committed Mar 31, 2022
1 parent d796cc2 commit 22859c7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface UserProvidedCodeArgs {
category?: string
"github-auth"?: string
"disable-update-check"?: boolean
"disable-file-downloads"?: boolean
}

/**
Expand Down Expand Up @@ -157,6 +158,11 @@ export const options: Options<Required<UserProvidedArgs>> = {
"Disable update check. Without this flag, code-server checks every 6 hours against the latest github release and \n" +
"then notifies you once every week that a new release is available.",
},
"disable-file-downloads": {
type: "boolean",
description:
"Disable file downloads from Code. Defaults to true.",
},
// --enable can be used to enable experimental features. These features
// provide no guarantees.
enable: { type: "string[]" },
Expand Down Expand Up @@ -445,6 +451,7 @@ export interface DefaultedArgs extends ConfigArgs {
usingEnvHashedPassword: boolean
"extensions-dir": string
"user-data-dir": string
"disable-file-downloads": boolean
/* Positional arguments. */
_: string[]
}
Expand Down Expand Up @@ -556,6 +563,10 @@ export async function setDefaults(cliArgs: UserProvidedArgs, configArgs?: Config
const proxyDomains = new Set((args["proxy-domain"] || []).map((d) => d.replace(/^\*\./, "")))
args["proxy-domain"] = Array.from(proxyDomains)

if (!args["disable-file-downloads"]) {
args["disable-file-downloads"] = false
}

if (typeof args._ === "undefined") {
args._ = []
}
Expand Down
4 changes: 4 additions & 0 deletions test/unit/node/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const defaults = {
host: "localhost",
port: 8080,
"proxy-domain": [],
"disable-file-downloads": false,
usingEnvPassword: false,
usingEnvHashedPassword: false,
"extensions-dir": path.join(paths.data, "extensions"),
Expand Down Expand Up @@ -92,6 +93,8 @@ describe("parser", () => {

"--port=8081",

"--disable-file-downloads",

["--host", "0.0.0.0"],
"4",
"--",
Expand All @@ -108,6 +111,7 @@ describe("parser", () => {
cert: {
value: path.resolve("path/to/cert"),
},
"disable-file-downloads": true,
enable: ["feature1", "feature2"],
help: true,
host: "0.0.0.0",
Expand Down
1 change: 1 addition & 0 deletions test/unit/node/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe("plugin", () => {
"proxy-domain": [],
config: "~/.config/code-server/config.yaml",
verbose: false,
"disable-file-downloads": false,
usingEnvPassword: false,
usingEnvHashedPassword: false,
"extensions-dir": "",
Expand Down

0 comments on commit 22859c7

Please sign in to comment.