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

Add support to CODER_BINARY_DESTINATION environment variable#597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
EhabY merged 2 commits intocoder:mainfromEhabY:coder-binary-destination-env-var
Oct 1, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletionsCHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,10 @@

## Unreleased

### Added

- Support for `CODER_BINARY_DESTINATION` environment variable to set CLI download location (overridden by extension setting `coder.binaryDestination` if configured).

## [v1.11.0](https://github.com/coder/vscode-coder/releases/tag/v1.11.0) 2025-09-24

### Changed
Expand Down
2 changes: 1 addition & 1 deletionpackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,7 +56,7 @@
"default": ""
},
"coder.binaryDestination": {
"markdownDescription": "The full path of the directory into which the Coder CLI will be downloaded. Defaults to the extension's global storage directory.",
"markdownDescription": "The full path of the directory into which the Coder CLI will be downloaded. Defaults to thevalue of `CODER_BINARY_DESTINATION` if not set, otherwise theextension's global storage directory.",
"type": "string",
"default": ""
},
Expand Down
9 changes: 6 additions & 3 deletionssrc/commands.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,10 +102,13 @@ export class Commands {
* CODER_URL or enter a new one. Undefined means the user aborted.
*/
private async askURL(selection?: string): Promise<string | undefined> {
const defaultURL =
vscode.workspace.getConfiguration().get<string>("coder.defaultUrl") ?? "";
const defaultURL = vscode.workspace
.getConfiguration()
.get<string>("coder.defaultUrl")
?.trim();
const quickPick = vscode.window.createQuickPick();
quickPick.value = selection || defaultURL || process.env.CODER_URL || "";
quickPick.value =
selection || defaultURL || process.env.CODER_URL?.trim() || "";
quickPick.placeholder = "https://example.coder.com";
quickPick.title = "Enter the URL of your Coder deployment.";

Expand Down
27 changes: 25 additions & 2 deletionssrc/core/pathResolver.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import * as path from "path";
import { describe, it, expect, beforeEach } from "vitest";
import { describe, it, expect, beforeEach, vi } from "vitest";
import { MockConfigurationProvider } from "../__mocks__/testHelpers";
import { PathResolver } from "./pathResolver";

Expand All@@ -11,6 +11,7 @@ describe("PathResolver", () => {
let mockConfig: MockConfigurationProvider;

beforeEach(() => {
vi.unstubAllEnvs();
pathResolver = new PathResolver(basePath, codeLogPath);
mockConfig = new MockConfigurationProvider();
});
Expand All@@ -32,6 +33,7 @@ describe("PathResolver", () => {
});

it("should use default path when custom destination is empty or whitespace", () => {
vi.stubEnv("CODER_BINARY_DESTINATION", " ");
mockConfig.set("coder.binaryDestination", " ");
expect(pathResolver.getBinaryCachePath("deployment")).toBe(
path.join(basePath, "deployment", "bin"),
Expand All@@ -41,7 +43,28 @@ describe("PathResolver", () => {
it("should normalize custom paths", () => {
mockConfig.set("coder.binaryDestination", "/custom/../binary/./path");
expect(pathResolver.getBinaryCachePath("deployment")).toBe(
path.normalize("/custom/../binary/./path"),
"/binary/path",
);
});

it("should use CODER_BINARY_DESTINATION environment variable with proper precedence", () => {
// Use the global storage when the environment variable and setting are unset/blank
vi.stubEnv("CODER_BINARY_DESTINATION", "");
mockConfig.set("coder.binaryDestination", "");
expect(pathResolver.getBinaryCachePath("deployment")).toBe(
path.join(basePath, "deployment", "bin"),
);

// Test environment variable takes precedence over global storage
vi.stubEnv("CODER_BINARY_DESTINATION", " /env/binary/path ");
expect(pathResolver.getBinaryCachePath("deployment")).toBe(
"/env/binary/path",
);

// Test setting takes precedence over environment variable
mockConfig.set("coder.binaryDestination", " /setting/path ");
expect(pathResolver.getBinaryCachePath("deployment")).toBe(
"/setting/path",
);
});
});
Expand Down
11 changes: 7 additions & 4 deletionssrc/core/pathResolver.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,11 +28,14 @@ export class PathResolver {
* The caller must ensure this directory exists before use.
*/
public getBinaryCachePath(label: string): string {
constconfigPath = vscode.workspace
constsettingPath = vscode.workspace
.getConfiguration()
.get<string>("coder.binaryDestination");
return configPath && configPath.trim().length > 0
? path.normalize(configPath)
.get<string>("coder.binaryDestination")
?.trim();
const binaryPath =
settingPath || process.env.CODER_BINARY_DESTINATION?.trim();
return binaryPath
? path.normalize(binaryPath)
: path.join(this.getGlobalConfigDir(label), "bin");
}

Expand Down
4 changes: 3 additions & 1 deletionsrc/extension.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -423,7 +423,9 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
// Handle autologin, if not already logged in.
const cfg = vscode.workspace.getConfiguration();
if (cfg.get("coder.autologin") === true) {
const defaultUrl = cfg.get("coder.defaultUrl") || process.env.CODER_URL;
const defaultUrl =
cfg.get<string>("coder.defaultUrl")?.trim() ||
process.env.CODER_URL?.trim();
if (defaultUrl) {
vscode.commands.executeCommand(
"coder.login",
Expand Down
4 changes: 2 additions & 2 deletionssrc/headers.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -123,9 +123,9 @@ describe("getHeaderCommand", () => {
expect(getHeaderCommand(config)).toBeUndefined();
});

it("should return undefined if coder.headerCommand isnot a string", () => {
it("should return undefined if coder.headerCommand isa blank string", () => {
const config = {
get: () =>1234,
get: () =>" ",
} as unknown as WorkspaceConfiguration;

expect(getHeaderCommand(config)).toBeUndefined();
Expand Down
9 changes: 4 additions & 5 deletionssrc/headers.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,11 +19,10 @@ export function getHeaderCommand(
config: WorkspaceConfiguration,
): string | undefined {
const cmd =
config.get("coder.headerCommand") || process.env.CODER_HEADER_COMMAND;
if (!cmd || typeof cmd !== "string") {
return undefined;
}
return cmd;
config.get<string>("coder.headerCommand")?.trim() ||
process.env.CODER_HEADER_COMMAND?.trim();

return cmd ? cmd : undefined;
}

export function getHeaderArgs(config: WorkspaceConfiguration): string[] {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp