Skip to content

feat: add version of Code OSS to output #4925

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/node/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const httpProxyUri =
* for outputting to the console.
*/
export function getVersionString(): string {
return [version, commit].join(" ")
return [version, commit, "with Code", codeVersion].join(" ")
}

/**
Expand Down
14 changes: 4 additions & 10 deletions src/node/entry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { logger } from "@coder/logger"
import { optionDescriptions, parse, readConfigFile, setDefaults, shouldOpenInExistingInstance } from "./cli"
import { commit, version } from "./constants"
import { getVersionString, getVersionJsonString } from "./constants"
import { openInExistingInstance, runCodeServer, runVsCodeCli, shouldSpawnCliProcess } from "./main"
import { isChild, wrapper } from "./wrapper"

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

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

if (args.version) {
if (args.json) {
console.log(
JSON.stringify({
codeServer: version,
commit,
vscode: require("../../vendor/modules/code-oss-dev/package.json").version,
}),
)
console.log(getVersionJsonString())
} else {
console.log(version, commit)
console.log(getVersionString())
}
return
}
Expand Down
6 changes: 4 additions & 2 deletions test/unit/node/constants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ describe("constants", () => {
})

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

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

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

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