fix: add untildify_user and use it everywhere

This commit is contained in:
Amin Yahyaabadi 2022-01-19 11:58:10 -08:00
parent 469230d988
commit f83c7d79ac
7 changed files with 22 additions and 10 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

@ -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 })

View File

@ -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[] = []

View File

@ -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")

View File

@ -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

View File

@ -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}`)
}
}