Skip to content

Commit 0e96c2b

Browse files
authored
fix: check for versions greater than 2.3.3 for the log-dir flag (#168)
1 parent 46d28cd commit 0e96c2b

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

src/remote.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { getHeaderCommand } from "./headers"
2424
import { SSHConfig, SSHValues, defaultSSHConfigResponse, mergeSSHConfigValues } from "./sshConfig"
2525
import { computeSSHProperties, sshSupportsSetEnv } from "./sshSupport"
2626
import { Storage } from "./storage"
27+
import { supportsCoderAgentLogDirFlag } from "./version"
2728
import { WorkspaceAction } from "./workspaceAction"
2829

2930
export class Remote {
@@ -76,10 +77,7 @@ export class Remote {
7677
await this.closeRemote()
7778
return
7879
}
79-
// CLI versions before 2.3.3 don't support the --log-dir flag!
80-
// If this check didn't exist, VS Code connections would fail on
81-
// older versions because of an unknown CLI argument.
82-
const hasCoderLogs = (parsedVersion?.compare("2.3.3") || 0) >= 0 || parsedVersion?.prerelease[0] === "devel"
80+
const hasCoderLogs = supportsCoderAgentLogDirFlag(parsedVersion)
8381

8482
// Find the workspace from the URI scheme provided!
8583
try {

src/version.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { parse } from "semver"
2+
import { describe, expect, it } from "vitest"
3+
import { supportsCoderAgentLogDirFlag } from "./version"
4+
5+
describe("check version support", () => {
6+
it("has logs", () => {
7+
expect(supportsCoderAgentLogDirFlag(parse("v1.3.3+e491217"))).toBeFalsy()
8+
expect(supportsCoderAgentLogDirFlag(parse("v2.3.3+e491217"))).toBeFalsy()
9+
expect(supportsCoderAgentLogDirFlag(parse("v2.3.4+e491217"))).toBeTruthy()
10+
expect(supportsCoderAgentLogDirFlag(parse("v5.3.4+e491217"))).toBeTruthy()
11+
expect(supportsCoderAgentLogDirFlag(parse("v5.0.4+e491217"))).toBeTruthy()
12+
})
13+
})

src/version.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { SemVer } from "semver"
2+
3+
// CLI versions before 2.3.3 don't support the --log-dir flag!
4+
// If this check didn't exist, VS Code connections would fail on
5+
// older versions because of an unknown CLI argument.
6+
export const supportsCoderAgentLogDirFlag = (ver: SemVer | null): boolean => {
7+
return (ver?.compare("2.3.3") || 0) > 0 || ver?.prerelease[0] === "devel"
8+
}

0 commit comments

Comments
 (0)