From a57ee6982233b7e451a963d1ce3530f40bd7173a Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Mon, 10 May 2021 16:17:30 -0700 Subject: [PATCH] feat: add runtime to getEnvPaths --- src/node/util.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/node/util.ts b/src/node/util.ts index 380e32b9..2633d3d5 100644 --- a/src/node/util.ts +++ b/src/node/util.ts @@ -7,10 +7,12 @@ import * as os from "os" import * as path from "path" import * as util from "util" import xdgBasedir from "xdg-basedir" +import { tmpdir } from "./constants" interface Paths { data: string config: string + runtime: string } export const paths = getEnvPaths() @@ -20,12 +22,15 @@ export const paths = getEnvPaths() * On MacOS this function gets the standard XDG directories instead of using the native macOS * ones. Most CLIs do this as in practice only GUI apps use the standard macOS directories. */ -function getEnvPaths(): Paths { +export function getEnvPaths(): Paths { let paths: Paths if (process.platform === "win32") { - paths = envPaths("code-server", { - suffix: "", - }) + paths = { + ...envPaths("code-server", { + suffix: "", + }), + runtime: tmpdir, + } } else { if (xdgBasedir.data === undefined || xdgBasedir.config === undefined) { throw new Error("No home folder?") @@ -33,6 +38,7 @@ function getEnvPaths(): Paths { paths = { data: path.join(xdgBasedir.data, "code-server"), config: path.join(xdgBasedir.config, "code-server"), + runtime: xdgBasedir.runtime ? path.join(xdgBasedir.runtime, "code-server") : tmpdir, } }