Skip to content

Commit 2c78577

Browse files
authored
feat: add version of Code OSS to output (#4925)
Show the bundled version of Code OSS in the text-based output for --version and --help, in addition to the JSON output (--version --json) Closes: #4874
1 parent 506d3f4 commit 2c78577

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

src/node/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const httpProxyUri =
3535
* for outputting to the console.
3636
*/
3737
export function getVersionString(): string {
38-
return [version, commit].join(" ")
38+
return [version, commit, "with Code", codeVersion].join(" ")
3939
}
4040

4141
/**

src/node/entry.ts

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { logger } from "@coder/logger"
22
import { optionDescriptions, parse, readConfigFile, setDefaults, shouldOpenInExistingInstance } from "./cli"
3-
import { commit, version } from "./constants"
3+
import { getVersionString, getVersionJsonString } from "./constants"
44
import { openInExistingInstance, runCodeServer, runVsCodeCli, shouldSpawnCliProcess } from "./main"
55
import { isChild, wrapper } from "./wrapper"
66

@@ -24,7 +24,7 @@ async function entry(): Promise<void> {
2424
const args = await setDefaults(cliArgs, configArgs)
2525

2626
if (args.help) {
27-
console.log("code-server", version, commit)
27+
console.log("code-server", getVersionString())
2828
console.log("")
2929
console.log(`Usage: code-server [options] [path]`)
3030
console.log(` - Opening a directory: code-server ./path/to/your/project`)
@@ -39,15 +39,9 @@ async function entry(): Promise<void> {
3939

4040
if (args.version) {
4141
if (args.json) {
42-
console.log(
43-
JSON.stringify({
44-
codeServer: version,
45-
commit,
46-
vscode: require("../../vendor/modules/code-oss-dev/package.json").version,
47-
}),
48-
)
42+
console.log(getVersionJsonString())
4943
} else {
50-
console.log(version, commit)
44+
console.log(getVersionString())
5145
}
5246
return
5347
}

test/unit/node/constants.test.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ describe("constants", () => {
6060
})
6161

6262
it("should return a human-readable version string", () => {
63-
expect(constants.getVersionString()).toStrictEqual(`${mockPackageJson.version} ${mockPackageJson.commit}`)
63+
expect(constants.getVersionString()).toStrictEqual(
64+
`${mockPackageJson.version} ${mockPackageJson.commit} with Code ${mockCodePackageJson.version}`,
65+
)
6466
})
6567

6668
it("should return a machine-readable version string", () => {
@@ -124,7 +126,7 @@ describe("constants", () => {
124126

125127
it("should return a human-readable version string", () => {
126128
// this string is not super useful
127-
expect(constants.getVersionString()).toStrictEqual("development development")
129+
expect(constants.getVersionString()).toStrictEqual("development development with Code development")
128130
})
129131

130132
it("should return a machine-readable version string", () => {

0 commit comments

Comments
 (0)