mirror of https://github.com/aminya/setup-cpp
refactor: use untildify_user in addEnv
This commit is contained in:
parent
70649cf39d
commit
a19fcfecdf
|
@ -3,8 +3,6 @@ import * as core from "@actions/core"
|
||||||
import { isGitHubCI } from "./isci"
|
import { isGitHubCI } from "./isci"
|
||||||
import { untildify_user as untildify } from "../path/untildify"
|
import { untildify_user as untildify } from "../path/untildify"
|
||||||
import { appendFileSync } from "fs"
|
import { appendFileSync } from "fs"
|
||||||
import { join } from "path"
|
|
||||||
import { isRoot } from "./sudo"
|
|
||||||
import { error } from "../io/io"
|
import { error } from "../io/io"
|
||||||
import { execPowershell } from "../exec/powershell"
|
import { execPowershell } from "../exec/powershell"
|
||||||
|
|
||||||
|
@ -39,12 +37,7 @@ function addEnvSystem(name: string, valGiven: string | undefined) {
|
||||||
case "linux":
|
case "linux":
|
||||||
case "darwin": {
|
case "darwin": {
|
||||||
// find profile path
|
// find profile path
|
||||||
let profile_path = untildify(".profile")
|
const 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")
|
|
||||||
}
|
|
||||||
|
|
||||||
appendFileSync(profile_path, `\nexport ${name}="${val}"\n`)
|
appendFileSync(profile_path, `\nexport ${name}="${val}"\n`)
|
||||||
core.info(`${name}="${val} was added to "${profile_path}"`)
|
core.info(`${name}="${val} was added to "${profile_path}"`)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue