Merge pull request #57 from aminya/vcpkg [skip ci]

This commit is contained in:
Amin Yahyaabadi 2022-04-24 18:13:00 -07:00 committed by GitHub
commit d35f6780f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -3,6 +3,8 @@ import execa from "execa"
import { existsSync } from "fs"
import { dirname, join } from "path"
import which from "which"
import { isRoot } from "../utils/env/sudo"
import { execSudo } from "../utils/exec/sudo"
import { addShellExtension, addShellHere } from "../utils/extension/extension"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { InstallationInfo } from "../utils/setup/setupBin"
@ -29,6 +31,16 @@ export async function setupVcpkg(_version: string, setupDir: string, _arch: stri
}
execa.sync(addShellExtension(addShellHere("bootstrap-vcpkg")), { cwd: setupDir, shell: true, stdio: "inherit" })
// change the owner to the SUDO_USER in setupDir. vcpkg requires this so it can install things without sudo
if (
(process.platform === "linux" || process.platform === "darwin") &&
isRoot() &&
process.env.SUDO_USER !== undefined
) {
await execSudo("chown", ["-R", process.env.SUDO_USER, setupDir], setupDir)
}
addPath(setupDir)
// eslint-disable-next-line require-atomic-updates
hasVCPKG = true