From 92bf2c976068b513256a909cbe8822e460c96524 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 5 May 2021 10:16:01 -0500 Subject: [PATCH] Add dev mode constant --- src/node/constants.ts | 1 + src/node/routes/vscode.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/node/constants.ts b/src/node/constants.ts index c198f8fb..d36f9a24 100644 --- a/src/node/constants.ts +++ b/src/node/constants.ts @@ -20,3 +20,4 @@ export const version = pkg.version || "development" export const commit = pkg.commit || "development" export const rootPath = path.resolve(__dirname, "../..") export const tmpdir = path.join(os.tmpdir(), "code-server") +export const isDevMode = commit === "development" diff --git a/src/node/routes/vscode.ts b/src/node/routes/vscode.ts index 0d9c6309..287216ec 100644 --- a/src/node/routes/vscode.ts +++ b/src/node/routes/vscode.ts @@ -7,7 +7,7 @@ import * as ipc from "../../../typings/ipc" import { Emitter } from "../../common/emitter" import { HttpCode, HttpError } from "../../common/http" import { getFirstString } from "../../common/util" -import { commit, rootPath, version } from "../constants" +import { isDevMode, rootPath, version } from "../constants" import { authenticated, ensureAuthenticated, redirect, replaceTemplates } from "../http" import { getMediaMime, pathToFsPath } from "../util" import { VscodeProvider } from "../vscode" @@ -31,7 +31,7 @@ router.get("/", async (req, res) => { try { return await vscode.initialize({ args: req.args, remoteAuthority: req.headers.host || "" }, req.query) } catch (error) { - const devMessage = commit === "development" ? "It might not have finished compiling." : "" + const devMessage = isDevMode ? "It might not have finished compiling." : "" throw new Error(`VS Code failed to load. ${devMessage} ${error.message}`) } })(), @@ -44,7 +44,7 @@ router.get("/", async (req, res) => { req, // Uncomment prod blocks if not in development. TODO: Would this be // better as a build step? Or maintain two HTML files again? - commit !== "development" ? content.replace(//g, "") : content, + !isDevMode ? content.replace(//g, "") : content, { authed: req.args.auth !== "none", disableTelemetry: !!req.args["disable-telemetry"],