2020-10-16 19:45:49 +00:00
|
|
|
import { logger } from "@coder/logger"
|
2021-02-08 23:21:30 +00:00
|
|
|
import { JSONSchemaForNPMPackageJsonFiles } from "@schemastore/package"
|
2021-04-21 20:22:11 +00:00
|
|
|
import * as os from "os"
|
2020-10-16 19:45:49 +00:00
|
|
|
import * as path from "path"
|
|
|
|
|
2021-02-08 23:21:30 +00:00
|
|
|
export function getPackageJson(relativePath: string): JSONSchemaForNPMPackageJsonFiles {
|
|
|
|
let pkg = {}
|
|
|
|
try {
|
|
|
|
pkg = require(relativePath)
|
|
|
|
} catch (error) {
|
|
|
|
logger.warn(error.message)
|
|
|
|
}
|
|
|
|
|
|
|
|
return pkg
|
2020-10-16 19:45:49 +00:00
|
|
|
}
|
|
|
|
|
2021-02-08 23:21:30 +00:00
|
|
|
const pkg = getPackageJson("../../package.json")
|
|
|
|
|
2020-10-16 19:45:49 +00:00
|
|
|
export const version = pkg.version || "development"
|
|
|
|
export const commit = pkg.commit || "development"
|
|
|
|
export const rootPath = path.resolve(__dirname, "../..")
|
2021-04-21 20:22:11 +00:00
|
|
|
export const tmpdir = path.join(os.tmpdir(), "code-server")
|
2021-05-05 15:16:01 +00:00
|
|
|
export const isDevMode = commit === "development"
|