code-server/packages/server/src/constants.ts

12 lines
692 B
TypeScript
Raw Normal View History

2019-03-07 17:24:25 +00:00
import * as path from "path";
import * as os from "os";
2019-03-07 17:24:25 +00:00
2019-02-07 17:47:00 +00:00
export const isCli = typeof process.env.CLI !== "undefined" && process.env.CLI !== "false";
export const serveStatic = typeof process.env.SERVE_STATIC !== "undefined" && process.env.SERVE_STATIC !== "false";
2019-03-07 17:24:25 +00:00
export const buildDir = process.env.BUILD_DIR ? path.resolve(process.env.BUILD_DIR) : "";
const xdgResolve = (primary: string | undefined, fallback: string): string => {
return primary ? path.resolve(primary) : path.resolve(process.env.HOME || os.homedir(), fallback);
};
export const dataHome = xdgResolve(process.env.XDG_DATA_HOME, ".local/share");
export const cacheHome = xdgResolve(process.env.XDG_CACHE_HOME, ".cache");