Skip to content

Commit c76683f

Browse files
committed
cover development strings
1 parent d3ccafc commit c76683f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/node/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const version = pkg.version || "development"
2323
export const commit = pkg.commit || "development"
2424
export const rootPath = path.resolve(__dirname, "../..")
2525
export const vsRootPath = path.join(rootPath, "vendor/modules/code-oss-dev")
26-
export const codeVersion = require(path.join(vsRootPath, "package.json")).version
26+
export const codeVersion = require(path.join(vsRootPath, "package.json")).version || "development"
2727
export const tmpdir = path.join(os.tmpdir(), "code-server")
2828
export const isDevMode = commit === "development"
2929
export const httpProxyUri =

test/unit/node/constants.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,18 @@ describe("constants", () => {
119119
it("commit should return 'development'", () => {
120120
expect(constants.commit).toBe("development")
121121
})
122+
123+
it("should return a human-readable version string", () => {
124+
// this string is not super useful
125+
expect(constants.getVersionString()).toStrictEqual("development development")
126+
})
127+
128+
it("should return a machine-readable version string", () => {
129+
expect(constants.getVersionJsonString()).toStrictEqual(JSON.stringify({
130+
codeServer: "development",
131+
commit: "development",
132+
vscode: "development",
133+
}))
134+
})
122135
})
123136
})

0 commit comments

Comments
 (0)