Skip to content

Commit fca9be5

Browse files
committed
fix: fix the vcpkg shell extension
1 parent 0c29f0b commit fca9be5

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

src/utils/extension/extension.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/** Add bin extension to a binary. This will be `.exe` on Windows. */
2+
export function addBinExtension(name: string) {
3+
if (process.platform === "win32") {
4+
return `${name}.exe`
5+
}
6+
return name
7+
}
8+
9+
/** Add native shell extension. This will be `.bat` on Windows and `sh` on unix. */
10+
export function addShellExtension(name: string) {
11+
if (process.platform === "win32") {
12+
return `${name}.bat`
13+
}
14+
return `${name}.sh`
15+
}

src/utils/setup/setupBin.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,3 @@ export async function setupBin(
8989

9090
return { installDir, binDir }
9191
}
92-
/** Add bin extension to a binary. This will be `.exe` on Windows. */
93-
export function addBinExtension(name: string) {
94-
if (process.platform === "win32") {
95-
return `${name}.exe`
96-
}
97-
return name
98-
}

src/utils/tests/test-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as io from "@actions/io"
22
import { tmpdir } from "os"
33
import * as path from "path"
4-
import { addBinExtension } from "../setup/setupBin"
4+
import { addBinExtension } from "../extension/extension"
55
import { join } from "path"
66
import spawn from "cross-spawn"
77

src/vcpkg/vcpkg.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import execa from "execa"
33
import path from "path"
44
import untildify from "untildify"
55
import which from "which"
6+
import { addShellExtension } from "../utils/extension/extension"
67
import { InstallationInfo } from "../utils/setup/setupBin"
78

89
let hasVCPKG = false
@@ -12,7 +13,7 @@ export function setupVcpkg(_version: string, _setupCppDir: string, _arch: string
1213
if (!hasVCPKG || which.sync("vcpkg", { nothrow: true }) === null) {
1314
execa.sync("git", ["clone", "https://github.com/microsoft/vcpkg"], { cwd: untildify("~/") })
1415
const vcpkgDir = untildify("~/vcpkg")
15-
execa.sync("./vcpkg/bootstrap-vcpkg", { cwd: vcpkgDir, shell: true })
16+
execa.sync(addShellExtension("./vcpkg/bootstrap-vcpkg"), { cwd: vcpkgDir, shell: true })
1617
addPath(vcpkgDir)
1718
hasVCPKG = true
1819
return { binDir: vcpkgDir }

0 commit comments

Comments
 (0)