refactor: use untildify_user in addEnv

This commit is contained in:
Amin Yahyaabadi 2022-02-28 21:51:52 -08:00
parent 70649cf39d
commit a19fcfecdf
1 changed files with 1 additions and 8 deletions

View File

@ -3,8 +3,6 @@ import * as core from "@actions/core"
import { isGitHubCI } from "./isci"
import { untildify_user as untildify } from "../path/untildify"
import { appendFileSync } from "fs"
import { join } from "path"
import { isRoot } from "./sudo"
import { error } from "../io/io"
import { execPowershell } from "../exec/powershell"
@ -39,12 +37,7 @@ function addEnvSystem(name: string, valGiven: string | undefined) {
case "linux":
case "darwin": {
// find profile path
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")
}
const profile_path = untildify(".profile")
appendFileSync(profile_path, `\nexport ${name}="${val}"\n`)
core.info(`${name}="${val} was added to "${profile_path}"`)
return