mirror of https://github.com/aminya/setup-cpp
fix: add untildify_user and use it everywhere
This commit is contained in:
parent
469230d988
commit
f83c7d79ac
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
import execa from "execa"
|
||||
// import { join } from "path"
|
||||
// import untildify from "untildify"
|
||||
// import { untildify_user as untildify } from "./utils/path/untildify"
|
||||
// import { setupCmake } from "../cmake/cmake"
|
||||
import { execaSudo } from "../utils/env/sudo"
|
||||
import { addBinExtension } from "../utils/extension/extension"
|
||||
|
@ -33,7 +33,7 @@ function getKcovPackageInfo(version: string): PackageInfo {
|
|||
extractFunction: async (file: string, dest: string): Promise<string> => {
|
||||
const out = await extractTarByExe(file, dest)
|
||||
// build after extraction using CMake
|
||||
// await setupCmake("3.22.0", join(untildify("~/"), "cmake"), "")
|
||||
// await setupCmake("3.22.0", join(untildify(""), "cmake"), "")
|
||||
await setupAptPack("libdw-dev")
|
||||
await setupAptPack("libcurl4-openssl-dev")
|
||||
await execa("cmake", ["-S", "./", "-B", "./build"], { cwd: out })
|
||||
|
|
|
@ -14,7 +14,7 @@ import { setupNinja } from "./ninja/ninja"
|
|||
import { setupOpencppcoverage } from "./opencppcoverage/opencppcoverage"
|
||||
import { setupPython } from "./python/python"
|
||||
import mri from "mri"
|
||||
import untildify from "untildify"
|
||||
import { untildify_user as untildify } from "./utils/path/untildify"
|
||||
import { isGitHubCI } from "./utils/env/isci"
|
||||
|
||||
import semverValid from "semver/functions/valid"
|
||||
|
@ -101,7 +101,7 @@ export async function main(args: string[]): Promise<number> {
|
|||
const arch = opts.architecture ?? process.arch
|
||||
|
||||
// the installation dir for the tools that are downloaded directly
|
||||
const setupCppDir = process.env.SETUP_CPP_DIR ?? untildify("~/")
|
||||
const setupCppDir = process.env.SETUP_CPP_DIR ?? untildify("")
|
||||
|
||||
// report messages
|
||||
const successMessages: string[] = []
|
||||
|
|
|
@ -2,7 +2,7 @@ import { exportVariable } from "@actions/core"
|
|||
import * as core from "@actions/core"
|
||||
import execa from "execa"
|
||||
import { isGitHubCI } from "./isci"
|
||||
import untildify from "untildify"
|
||||
import { untildify_user as untildify } from "../path/untildify"
|
||||
import { appendFileSync } from "fs"
|
||||
import { join } from "path"
|
||||
import { isRoot } from "./sudo"
|
||||
|
@ -36,7 +36,7 @@ function addEnvSystem(name: string, val: string | undefined) {
|
|||
case "linux":
|
||||
case "darwin": {
|
||||
// find profile path
|
||||
let profile_path = untildify("~/.profile")
|
||||
let profile_path = untildify(".profile")
|
||||
if (isRoot() && typeof process.env.SUDO_USER === "string") {
|
||||
// use the user profile even if root
|
||||
profile_path = join("/home/", process.env.SUDO_USER, ".profile")
|
||||
|
|
|
@ -3,7 +3,7 @@ import { delimiter } from "path"
|
|||
import * as core from "@actions/core"
|
||||
import execa from "execa"
|
||||
import { isGitHubCI } from "../env/isci"
|
||||
import untildify from "untildify"
|
||||
import { untildify_user as untildify } from "./untildify"
|
||||
import { appendFileSync } from "fs"
|
||||
|
||||
/** An add path function that works locally or inside GitHub Actions */
|
||||
|
@ -34,7 +34,7 @@ function addPathSystem(path: string) {
|
|||
}
|
||||
case "linux":
|
||||
case "darwin": {
|
||||
const profile_path = untildify("~/.profile")
|
||||
const profile_path = untildify(".profile")
|
||||
appendFileSync(profile_path, `\nexport PATH=${path}:$PATH\n`)
|
||||
core.info(`${path} was added to "${profile_path}"`)
|
||||
return
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
import { join } from "path"
|
||||
import untildify from "untildify"
|
||||
import { isRoot } from "../env/sudo"
|
||||
|
||||
export function untildify_user(path: string) {
|
||||
if (isRoot() && typeof process.env.SUDO_USER === "string") {
|
||||
// use the user profile even if root
|
||||
return join("/home/", process.env.SUDO_USER, path)
|
||||
} else {
|
||||
return untildify(`~/${path}`)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue