fix: fix the vcpkg shell extension

This commit is contained in:
Amin Yahyaabadi 2021-11-21 11:26:47 -06:00
parent 0c29f0b7a3
commit fca9be5e81
4 changed files with 18 additions and 9 deletions

View File

@ -0,0 +1,15 @@
/** Add bin extension to a binary. This will be `.exe` on Windows. */
export function addBinExtension(name: string) {
if (process.platform === "win32") {
return `${name}.exe`
}
return name
}
/** Add native shell extension. This will be `.bat` on Windows and `sh` on unix. */
export function addShellExtension(name: string) {
if (process.platform === "win32") {
return `${name}.bat`
}
return `${name}.sh`
}

View File

@ -89,10 +89,3 @@ export async function setupBin(
return { installDir, binDir }
}
/** Add bin extension to a binary. This will be `.exe` on Windows. */
export function addBinExtension(name: string) {
if (process.platform === "win32") {
return `${name}.exe`
}
return name
}

View File

@ -1,7 +1,7 @@
import * as io from "@actions/io"
import { tmpdir } from "os"
import * as path from "path"
import { addBinExtension } from "../setup/setupBin"
import { addBinExtension } from "../extension/extension"
import { join } from "path"
import spawn from "cross-spawn"

View File

@ -3,6 +3,7 @@ import execa from "execa"
import path from "path"
import untildify from "untildify"
import which from "which"
import { addShellExtension } from "../utils/extension/extension"
import { InstallationInfo } from "../utils/setup/setupBin"
let hasVCPKG = false
@ -12,7 +13,7 @@ export function setupVcpkg(_version: string, _setupCppDir: string, _arch: string
if (!hasVCPKG || which.sync("vcpkg", { nothrow: true }) === null) {
execa.sync("git", ["clone", "https://github.com/microsoft/vcpkg"], { cwd: untildify("~/") })
const vcpkgDir = untildify("~/vcpkg")
execa.sync("./vcpkg/bootstrap-vcpkg", { cwd: vcpkgDir, shell: true })
execa.sync(addShellExtension("./vcpkg/bootstrap-vcpkg"), { cwd: vcpkgDir, shell: true })
addPath(vcpkgDir)
hasVCPKG = true
return { binDir: vcpkgDir }