From 4b6cbacbad522ceb259845bc6d315aa8310a2945 Mon Sep 17 00:00:00 2001 From: Asher Date: Fri, 16 Oct 2020 14:45:49 -0500 Subject: [PATCH] Add file for global constants --- src/node/constants.ts | 13 +++++++++++++ src/node/entry.ts | 11 +---------- 2 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 src/node/constants.ts diff --git a/src/node/constants.ts b/src/node/constants.ts new file mode 100644 index 000000000..d6ba953ea --- /dev/null +++ b/src/node/constants.ts @@ -0,0 +1,13 @@ +import { logger } from "@coder/logger" +import * as path from "path" + +let pkg: { version?: string; commit?: string } = {} +try { + pkg = require("../../package.json") +} catch (error) { + logger.warn(error.message) +} + +export const version = pkg.version || "development" +export const commit = pkg.commit || "development" +export const rootPath = path.resolve(__dirname, "../..") diff --git a/src/node/entry.ts b/src/node/entry.ts index e8c6b4e1f..ce0d2980f 100644 --- a/src/node/entry.ts +++ b/src/node/entry.ts @@ -17,20 +17,11 @@ import { shouldRunVsCodeCli, } from "./cli" import { coderCloudBind } from "./coder-cloud" +import { commit, version } from "./constants" import { loadPlugins } from "./plugin" import { humanPath, open } from "./util" import { ipcMain, WrapperProcess } from "./wrapper" -let pkg: { version?: string; commit?: string } = {} -try { - pkg = require("../../package.json") -} catch (error) { - logger.warn(error.message) -} - -const version = pkg.version || "development" -const commit = pkg.commit || "development" - export const runVsCodeCli = (args: DefaultedArgs): void => { logger.debug("forking vs code cli...") const vscode = cp.fork(path.resolve(__dirname, "../../lib/vscode/out/vs/server/fork"), [], {