Skip to content

Commit 866cbe3

Browse files
committed
feat: add runtime to getEnvPaths
1 parent 2de9557 commit 866cbe3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/node/util.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import * as os from "os"
77
import * as path from "path"
88
import * as util from "util"
99
import xdgBasedir from "xdg-basedir"
10+
import { tmpdir } from "./constants"
1011

1112
interface Paths {
1213
data: string
1314
config: string
15+
runtime: string
1416
}
1517

1618
export const paths = getEnvPaths()
@@ -20,19 +22,23 @@ export const paths = getEnvPaths()
2022
* On MacOS this function gets the standard XDG directories instead of using the native macOS
2123
* ones. Most CLIs do this as in practice only GUI apps use the standard macOS directories.
2224
*/
23-
function getEnvPaths(): Paths {
25+
export function getEnvPaths(): Paths {
2426
let paths: Paths
2527
if (process.platform === "win32") {
26-
paths = envPaths("code-server", {
27-
suffix: "",
28-
})
28+
paths = {
29+
...envPaths("code-server", {
30+
suffix: "",
31+
}),
32+
runtime: tmpdir,
33+
}
2934
} else {
3035
if (xdgBasedir.data === undefined || xdgBasedir.config === undefined) {
3136
throw new Error("No home folder?")
3237
}
3338
paths = {
3439
data: path.join(xdgBasedir.data, "code-server"),
3540
config: path.join(xdgBasedir.config, "code-server"),
41+
runtime: xdgBasedir.runtime ? path.join(xdgBasedir.runtime, "code-server") : tmpdir,
3642
}
3743
}
3844

0 commit comments

Comments
 (0)