Skip to content

Commit dfe8b7d

Browse files
committed
fixup! chore: update CHANGELOG
1 parent a19ec2a commit dfe8b7d

File tree

3 files changed

+37
-31
lines changed

3 files changed

+37
-31
lines changed

src/node/socket.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class SocketProxyProvider {
7676
.then((pipe) => {
7777
this.proxyPipe = pipe
7878
return Promise.all([
79-
fs.mkdir(path.dirname(this.proxyPath), { recursive: true }),
79+
fs.mkdir(path.dirname(this.proxyPipe), { recursive: true }),
8080
fs.rmdir(this.proxyPipe, { recursive: true }),
8181
])
8282
})

src/node/util.ts

+26-20
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ 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"
1110

1211
export interface Paths {
1312
data: string
@@ -23,26 +22,33 @@ export const paths = getEnvPaths()
2322
* ones. Most CLIs do this as in practice only GUI apps use the standard macOS directories.
2423
*/
2524
export function getEnvPaths(): Paths {
26-
let paths: Paths
27-
if (process.platform === "win32") {
28-
paths = {
29-
...envPaths("code-server", {
30-
suffix: "",
31-
}),
32-
runtime: tmpdir,
33-
}
34-
} else {
35-
if (xdgBasedir.data === undefined || xdgBasedir.config === undefined) {
36-
throw new Error("No home folder?")
37-
}
38-
paths = {
39-
data: path.join(xdgBasedir.data, "code-server"),
40-
config: path.join(xdgBasedir.config, "code-server"),
41-
runtime: xdgBasedir.runtime ? path.join(xdgBasedir.runtime, "code-server") : tmpdir,
42-
}
25+
const paths = envPaths("code-server", { suffix: "" })
26+
const append = (p: string): string => path.join(p, "code-server")
27+
switch (process.platform) {
28+
case "darwin":
29+
return {
30+
// envPaths uses native directories so force Darwin to use the XDG spec
31+
// to align with other CLI tools.
32+
data: xdgBasedir.data ? append(xdgBasedir.data) : paths.data,
33+
config: xdgBasedir.config ? append(xdgBasedir.config) : paths.config,
34+
// Fall back to temp if there is no runtime dir.
35+
runtime: xdgBasedir.runtime ? append(xdgBasedir.runtime) : paths.temp,
36+
}
37+
case "win32":
38+
return {
39+
data: paths.data,
40+
config: paths.config,
41+
// Windows doesn't have a runtime dir.
42+
runtime: paths.temp,
43+
}
44+
default:
45+
return {
46+
data: paths.data,
47+
config: paths.config,
48+
// Fall back to temp if there is no runtime dir.
49+
runtime: xdgBasedir.runtime ? append(xdgBasedir.runtime) : paths.temp,
50+
}
4351
}
44-
45-
return paths
4652
}
4753

4854
/**

test/unit/register.test.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe("register", () => {
99

1010
beforeAll(() => {
1111
const { window } = new JSDOM()
12-
global.window = window as unknown as Window & typeof globalThis
12+
global.window = (window as unknown) as Window & typeof globalThis
1313
global.document = window.document
1414
global.navigator = window.navigator
1515
global.location = window.location
@@ -35,10 +35,10 @@ describe("register", () => {
3535
jest.restoreAllMocks()
3636

3737
// We don't want these to stay around because it can affect other tests
38-
global.window = undefined as unknown as Window & typeof globalThis
39-
global.document = undefined as unknown as Document & typeof globalThis
40-
global.navigator = undefined as unknown as Navigator & typeof globalThis
41-
global.location = undefined as unknown as Location & typeof globalThis
38+
global.window = (undefined as unknown) as Window & typeof globalThis
39+
global.document = (undefined as unknown) as Document & typeof globalThis
40+
global.navigator = (undefined as unknown) as Navigator & typeof globalThis
41+
global.location = (undefined as unknown) as Location & typeof globalThis
4242
})
4343

4444
it("test should have access to browser globals from beforeAll", () => {
@@ -110,7 +110,7 @@ describe("register", () => {
110110
origin: "http://localhost:8080",
111111
}
112112
const { window } = new JSDOM()
113-
global.window = window as unknown as Window & typeof globalThis
113+
global.window = (window as unknown) as Window & typeof globalThis
114114
global.document = window.document
115115
global.navigator = window.navigator
116116
global.location = location as Location
@@ -131,10 +131,10 @@ describe("register", () => {
131131
jest.restoreAllMocks()
132132

133133
// We don't want these to stay around because it can affect other tests
134-
global.window = undefined as unknown as Window & typeof globalThis
135-
global.document = undefined as unknown as Document & typeof globalThis
136-
global.navigator = undefined as unknown as Navigator & typeof globalThis
137-
global.location = undefined as unknown as Location & typeof globalThis
134+
global.window = (undefined as unknown) as Window & typeof globalThis
135+
global.document = (undefined as unknown) as Document & typeof globalThis
136+
global.navigator = (undefined as unknown) as Navigator & typeof globalThis
137+
global.location = (undefined as unknown) as Location & typeof globalThis
138138
})
139139
it("should register when options.base is undefined", async () => {
140140
// Mock getElementById

0 commit comments

Comments
 (0)