Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1ad3a20

Browse files
committed
Address review comments + Add some tests
1 parentd008e31 commit1ad3a20

File tree

5 files changed

+94
-20
lines changed

5 files changed

+94
-20
lines changed

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
###Added
66

7-
- Add support for CLI global flag configurations.
7+
- Add support for CLI global flag configurations through the`coder.globalFlags` setting.
88

99
##[1.10.1](https://github.com/coder/vscode-coder/releases/tag/v1.10.1) 2025-08-13
1010

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
"default":false
122122
},
123123
"coder.globalFlags": {
124-
"markdownDescription":"Global flags to pass to every Coder CLI invocation. Enter each flag as a separate array item; values are passed verbatim and in order. Do **not** include the `coder` command itself. See the [CLI reference](https://coder.com/docs/reference/cli) for available global flags.\n\nNote that the `#coder.headerCommand#` setting **takes precedence** and will override any `--header-command` value specified here.",
124+
"markdownDescription":"Global flags to pass to every Coder CLI invocation. Enter each flag as a separate array item; values are passed verbatim and in order. Do **not** include the `coder` command itself. See the [CLI reference](https://coder.com/docs/reference/cli) for available global flags.\n\nNote that the `#coder.headerCommand#` setting **takes precedence** and will override any `--header-command` value specified here. The `--global-config` flag is explicitly ignored.",
125125
"type":"array",
126126
"items": {
127127
"type":"string"

‎src/globalFlags.test.ts‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import{it,expect,describe}from"vitest";
2+
import{WorkspaceConfiguration}from"vscode";
3+
import{getGlobalFlags}from"./globalFlags";
4+
5+
describe("Global flags suite",()=>{
6+
it("should return empty array when no global flags configured",()=>{
7+
constconfig={
8+
get:()=>undefined,
9+
}asunknownasWorkspaceConfiguration;
10+
11+
expect(getGlobalFlags(config,"")).toStrictEqual([]);
12+
});
13+
14+
it("should return global flags from config",()=>{
15+
constconfig={
16+
get:(key:string)=>
17+
key==="coder.globalFlags"
18+
?["--verbose","--disable-direct-connections"]
19+
:undefined,
20+
}asunknownasWorkspaceConfiguration;
21+
22+
expect(getGlobalFlags(config,"")).toStrictEqual([
23+
"--verbose",
24+
"--disable-direct-connections",
25+
]);
26+
});
27+
28+
it("should filter out '--global-config' flags",()=>{
29+
constconfig={
30+
get:(key:string)=>
31+
key==="coder.globalFlags"
32+
?[
33+
"-v",
34+
"--global-config=/path/to/config",
35+
"--disable-direct-connections",
36+
]
37+
:undefined,
38+
}asunknownasWorkspaceConfiguration;
39+
40+
expect(getGlobalFlags(config,"")).toStrictEqual([
41+
"-v",
42+
"--disable-direct-connections",
43+
]);
44+
});
45+
46+
it("should add '--global-config' args when configDir provided",()=>{
47+
constconfig={
48+
get:(key:string)=>
49+
key==="coder.globalFlags"
50+
?["-v",'--global-config "/ignored/path"']
51+
:undefined,
52+
}asunknownasWorkspaceConfiguration;
53+
54+
expect(getGlobalFlags(config,"/path/to/config")).toStrictEqual([
55+
"-v",
56+
"--global-config",
57+
'"/path/to/config"',
58+
]);
59+
});
60+
61+
it("should filter out '--header-command' when header args present",()=>{
62+
constconfig={
63+
get:(key:string)=>{
64+
if(key==="coder.headerCommand"){
65+
return"echo test";
66+
}
67+
if(key==="coder.globalFlags"){
68+
return["-v","--header-command=custom","--no-feature-warning"];
69+
}
70+
returnundefined;
71+
},
72+
}asunknownasWorkspaceConfiguration;
73+
74+
constresult=getGlobalFlags(config,"");
75+
expect(result).toStrictEqual([
76+
"-v",
77+
"--no-feature-warning",
78+
"--header-command",
79+
"'echo test'",
80+
]);
81+
});
82+
});

‎src/globalFlags.ts‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,23 @@ import { escapeCommandArg } from "./util";
44

55
exportfunctiongetGlobalFlags(
66
configs:WorkspaceConfiguration,
7-
configDir?:string,
7+
configDir:string,
88
):string[]{
99
constglobalFlags=configs.get<string[]>("coder.globalFlags")||[];
1010
constheaderArgs=getHeaderArgs(configs);
1111
constglobalConfigArgs=configDir
1212
?["--global-config",escapeCommandArg(configDir)]
1313
:[];
1414

15+
letfilteredGlobalFlags=globalFlags.filter(
16+
(flag)=>!flag.startsWith("--global-config"),
17+
);
1518
// Precedence of "coder.headerCommand" is higher than "coder.globalConfig" with the "--header-command" flag
16-
letfilteredGlobalFlags=globalFlags;
1719
if(headerArgs.length>0){
1820
filteredGlobalFlags=globalFlags.filter(
1921
(flag)=>!flag.startsWith("--header-command"),
2022
);
2123
}
2224

23-
if(globalConfigArgs.length>0){
24-
filteredGlobalFlags=globalFlags.filter(
25-
(flag)=>!flag.startsWith("--global-config"),
26-
);
27-
}
2825
return[...filteredGlobalFlags, ...headerArgs, ...globalConfigArgs];
2926
}

‎src/remote.ts‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ export class Remote {
762762
?`${AuthorityPrefix}.${label}--`
763763
:`${AuthorityPrefix}--`;
764764

765-
constglobalConfigs=this.globalConfigs(featureSet,label);
765+
constglobalConfigs=this.globalConfigs(label);
766766

767767
constproxyCommand=featureSet.wildcardSSH
768768
?`${escapeCommandArg(binaryPath)}${globalConfigs} ssh --stdio --usage-app=vscode --disable-autostart --network-info-dir${escapeCommandArg(this.storage.getNetworkInfoPath())}${awaitthis.formatLogArg(logDir)} --ssh-host-prefix${hostPrefix} %h`
@@ -824,17 +824,12 @@ export class Remote {
824824
returnsshConfig.getRaw();
825825
}
826826

827-
privateglobalConfigs(featureSet:FeatureSet,label:string):string{
827+
privateglobalConfigs(label:string):string{
828828
constvscodeConfig=vscode.workspace.getConfiguration();
829-
letargs:string[];
830-
if(featureSet.wildcardSSH){
831-
args=getGlobalFlags(
832-
vscodeConfig,
833-
path.dirname(this.storage.getSessionTokenPath(label)),
834-
);
835-
}else{
836-
args=getGlobalFlags(vscodeConfig);
837-
}
829+
constargs:string[]=getGlobalFlags(
830+
vscodeConfig,
831+
path.dirname(this.storage.getSessionTokenPath(label)),
832+
);
838833
returnargs.length===0 ?"" :`${args.join(" ")}`;
839834
}
840835

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp