Skip to content

Commit 22859c7

Browse files
committed
feat(cli): add disable-file-downloads to cli
1 parent d796cc2 commit 22859c7

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/node/cli.ts

+11
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export interface UserProvidedCodeArgs {
4949
category?: string
5050
"github-auth"?: string
5151
"disable-update-check"?: boolean
52+
"disable-file-downloads"?: boolean
5253
}
5354

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

566+
if (!args["disable-file-downloads"]) {
567+
args["disable-file-downloads"] = false
568+
}
569+
559570
if (typeof args._ === "undefined") {
560571
args._ = []
561572
}

test/unit/node/cli.test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const defaults = {
3131
host: "localhost",
3232
port: 8080,
3333
"proxy-domain": [],
34+
"disable-file-downloads": false,
3435
usingEnvPassword: false,
3536
usingEnvHashedPassword: false,
3637
"extensions-dir": path.join(paths.data, "extensions"),
@@ -92,6 +93,8 @@ describe("parser", () => {
9293

9394
"--port=8081",
9495

96+
"--disable-file-downloads",
97+
9598
["--host", "0.0.0.0"],
9699
"4",
97100
"--",
@@ -108,6 +111,7 @@ describe("parser", () => {
108111
cert: {
109112
value: path.resolve("path/to/cert"),
110113
},
114+
"disable-file-downloads": true,
111115
enable: ["feature1", "feature2"],
112116
help: true,
113117
host: "0.0.0.0",

test/unit/node/plugin.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ describe("plugin", () => {
3838
"proxy-domain": [],
3939
config: "~/.config/code-server/config.yaml",
4040
verbose: false,
41+
"disable-file-downloads": false,
4142
usingEnvPassword: false,
4243
usingEnvHashedPassword: false,
4344
"extensions-dir": "",

0 commit comments

Comments
 (0)