Skip to content

Commit 5996701

Browse files
committed
Output commit along with the version
1 parent ce637d3 commit 5996701

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "code-server",
33
"license": "MIT",
4-
"version": "3.0.1",
4+
"version": "3.0.2",
55
"scripts": {
66
"clean": "ci/clean.sh",
77
"vscode": "ci/vscode.sh",

src/node/entry.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,27 @@ import { SshProvider } from "./ssh/server"
1414
import { generateCertificate, generatePassword, generateSshHostKey, hash, open } from "./util"
1515
import { ipcMain, wrap } from "./wrapper"
1616

17+
let pkg: { version?: string; commit?: string } = {}
18+
try {
19+
pkg = require("../../package.json")
20+
} catch (error) {
21+
logger.warn(error.message)
22+
}
23+
24+
const version = pkg.version || "development"
25+
const commit = pkg.commit || "development"
26+
1727
const main = async (args: Args): Promise<void> => {
1828
const auth = args.auth || AuthType.Password
1929
const originalPassword = auth === AuthType.Password && (process.env.PASSWORD || (await generatePassword()))
2030

21-
let commit: string | undefined
22-
try {
23-
commit = require("../../package.json").commit
24-
} catch (error) {
25-
logger.warn(error.message)
26-
}
27-
2831
// Spawn the main HTTP server.
2932
const options = {
3033
auth,
3134
cert: args.cert ? args.cert.value : undefined,
3235
certKey: args["cert-key"],
3336
sshHostKey: args["ssh-host-key"],
34-
commit: commit || "development",
37+
commit,
3538
host: args.host || (args.auth === AuthType.Password && typeof args.cert !== "undefined" ? "0.0.0.0" : "localhost"),
3639
password: originalPassword ? hash(originalPassword) : undefined,
3740
port: typeof args.port !== "undefined" ? args.port : process.env.PORT ? parseInt(process.env.PORT, 10) : 8080,
@@ -68,7 +71,7 @@ const main = async (args: Args): Promise<void> => {
6871

6972
ipcMain().onDispose(() => httpServer.dispose())
7073

71-
logger.info(`code-server ${require("../../package.json").version}`)
74+
logger.info(`code-server ${version} ${commit}`)
7275

7376
let sshPort = ""
7477
if (!args["disable-ssh"] && options.sshHostKey) {
@@ -132,7 +135,7 @@ const tryParse = (): Args => {
132135

133136
const args = tryParse()
134137
if (args.help) {
135-
console.log("code-server", require("../../package.json").version)
138+
console.log("code-server", version, commit)
136139
console.log("")
137140
console.log(`Usage: code-server [options] [path]`)
138141
console.log("")
@@ -141,14 +144,14 @@ if (args.help) {
141144
console.log("", description)
142145
})
143146
} else if (args.version) {
144-
const version = require("../../package.json").version
145147
if (args.json) {
146148
console.log({
147149
codeServer: version,
150+
commit,
148151
vscode: require("../../lib/vscode/package.json").version,
149152
})
150153
} else {
151-
console.log(version)
154+
console.log(version, commit)
152155
}
153156
process.exit(0)
154157
} else if (args["list-extensions"] || args["install-extension"] || args["uninstall-extension"]) {

0 commit comments

Comments
 (0)