fix: allow specifying the vcpkg version

This commit is contained in:
Amin Yahyaabadi 2024-08-12 01:53:56 -07:00
parent 55af62e5b4
commit 1818c421dc
No known key found for this signature in database
GPG Key ID: F52AF77F636088F0
7 changed files with 20 additions and 9 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
import { grantUserWriteAccess } from "admina"
import { notice } from "ci-log"
import { info, notice } from "ci-log"
import { execaSync } from "execa"
import { pathExists } from "path-exists"
import { addShExt, addShRelativePrefix, dirname, join } from "patha"
@ -16,7 +16,7 @@ import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
let hasVCPKG = false
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function setupVcpkg(_version: string, setupDir: string, _arch: string): Promise<InstallationInfo> {
export async function setupVcpkg(version: string, setupDir: string, _arch: string): Promise<InstallationInfo> {
if (!hasVCPKG || which.sync("vcpkg", { nothrow: true }) === null) {
if (process.platform === "linux") {
// vcpkg download and extraction dependencies
@ -50,12 +50,23 @@ export async function setupVcpkg(_version: string, setupDir: string, _arch: stri
}
}
// clone if not already exists
if (!(await pathExists(join(setupDir, addShExt("bootstrap-vcpkg", ".bat"))))) {
execaSync("git", ["clone", "https://github.com/microsoft/vcpkg"], { cwd: dirname(setupDir), stdio: "inherit" })
} else {
notice(`Vcpkg folder already exists at ${setupDir}. This might mean that ~/vcpkg is restored from the cache.`)
notice(`Vcpkg folder already exists at ${setupDir}. Skipping the clone`)
}
// if version specified, checkout the version
if (!(version in ["", "true"])) {
info(`Checking out vcpkg version ${version}`)
execaSync("git", ["checkout", version], {
cwd: setupDir,
stdio: "inherit",
})
}
// bootstrap vcpkg
execaSync(addShExt(addShRelativePrefix("bootstrap-vcpkg"), ".bat"), {
cwd: setupDir,
shell: true,