fix(desktop): change detection on Windows, especially Cygwin (#13659)

Co-authored-by: LukeParkerDev <10430890+Hona@users.noreply.github.com>
This commit is contained in:
Erik Demaine
2026-02-22 18:49:05 -05:00
committed by GitHub
parent eb64ce08b8
commit a74fedd23b
9 changed files with 113 additions and 38 deletions

View File

@@ -286,6 +286,40 @@ describe("filesystem", () => {
})
})
describe("windowsPath()", () => {
test("converts Git Bash paths", () => {
if (process.platform === "win32") {
expect(Filesystem.windowsPath("/c/Users/test")).toBe("C:/Users/test")
expect(Filesystem.windowsPath("/d/dev/project")).toBe("D:/dev/project")
} else {
expect(Filesystem.windowsPath("/c/Users/test")).toBe("/c/Users/test")
}
})
test("converts Cygwin paths", () => {
if (process.platform === "win32") {
expect(Filesystem.windowsPath("/cygdrive/c/Users/test")).toBe("C:/Users/test")
expect(Filesystem.windowsPath("/cygdrive/x/dev/project")).toBe("X:/dev/project")
} else {
expect(Filesystem.windowsPath("/cygdrive/c/Users/test")).toBe("/cygdrive/c/Users/test")
}
})
test("converts WSL paths", () => {
if (process.platform === "win32") {
expect(Filesystem.windowsPath("/mnt/c/Users/test")).toBe("C:/Users/test")
expect(Filesystem.windowsPath("/mnt/z/dev/project")).toBe("Z:/dev/project")
} else {
expect(Filesystem.windowsPath("/mnt/c/Users/test")).toBe("/mnt/c/Users/test")
}
})
test("ignores normal Windows paths", () => {
expect(Filesystem.windowsPath("C:/Users/test")).toBe("C:/Users/test")
expect(Filesystem.windowsPath("D:\\dev\\project")).toBe("D:\\dev\\project")
})
})
describe("writeStream()", () => {
test("writes from Web ReadableStream", async () => {
await using tmp = await tmpdir()