Skip to content

Commit 74dee77

Browse files
committed
Build platform-agnostic paths
1 parent d955979 commit 74dee77

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

__tests__/visual-studio.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os from "os";
2+
import * as path from "path";
23
import * as vs from "../src/visual-studio";
34
import { swiftPackage } from "../src/swift-versions";
45
import { OS, System } from "../src/os";
@@ -70,16 +71,21 @@ describe("visual studio resolver", () => {
7071
});
7172

7273
it("finds vswhere path from environment value", async () => {
73-
const vswherePath = "C:\\bin\\";
74-
const vswhereExe = "C:\\bin\\vswhere.exe";
74+
const vswherePath = path.join("C:", "bin");
75+
const vswhereExe = path.join(vswherePath, "vswhere.exe");
7576
process.env.VSWHERE_PATH = vswherePath;
7677
expect(await vs.getVsWherePath()).toBe(vswhereExe);
7778
});
7879

7980
it("finds vswhere path from ProgramFiles environment value", async () => {
80-
const vswhereExe =
81-
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe";
82-
process.env["ProgramFiles(x86)"] = "C:\\Program Files (x86)";
81+
const vswhereExe = path.join(
82+
"C:",
83+
"Program Files (x86)",
84+
"Microsoft Visual Studio",
85+
"Installer",
86+
"vswhere.exe"
87+
);
88+
process.env["ProgramFiles(x86)"] = path.join("C:", "Program Files (x86)");
8389
expect(await vs.getVsWherePath()).toBe(vswhereExe);
8490
});
8591
});

src/visual-studio.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ export async function getVsWherePath() {
146146
// fall back to VS-installed path
147147
vswhereToolExe = path.join(
148148
process.env["ProgramFiles(x86)"] as string,
149-
"Microsoft Visual Studio\\Installer\\vswhere.exe"
149+
"Microsoft Visual Studio",
150+
"Installer",
151+
"vswhere.exe"
150152
);
151153
core.debug(`Trying Visual Studio-installed path: ${vswhereToolExe}`);
152154
}

src/windows-install.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export async function install(version: string, system: System) {
5757
"Developer",
5858
"Toolchains",
5959
"unknown-Asserts-development.xctoolchain",
60-
"usr\\bin"
60+
"usr",
61+
"bin"
6162
);
6263

6364
if (code != 0 || !fs.existsSync(swiftInstallPath)) {
@@ -67,8 +68,8 @@ export async function install(version: string, system: System) {
6768
core.addPath(swiftInstallPath);
6869

6970
const additionalPaths = [
70-
path.join(swiftLibPath, "Swift-development\\bin"),
71-
path.join(swiftLibPath, "icu-67\\usr\\bin"),
71+
path.join(swiftLibPath, "Swift-development", "bin"),
72+
path.join(swiftLibPath, "icu-67", "usr", "bin"),
7273
];
7374
additionalPaths.forEach((value, index, array) => core.addPath(value));
7475

0 commit comments

Comments
 (0)