fix: append update-alternatives to cpprc instead

This commit is contained in:
Amin Yahyaabadi 2022-04-18 23:47:37 -07:00
parent dea371a1d9
commit a6e315987a
4 changed files with 16 additions and 5 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

@ -45,7 +45,7 @@ export function addPath(path: string) {
}
}
const cpprc_path = untildify(".cpprc")
export const cpprc_path = untildify(".cpprc")
function addEnvSystem(name: string, valGiven: string | undefined) {
const val = valGiven ?? ""
@ -96,7 +96,7 @@ function addPathSystem(path: string) {
let setupCppInProfile_called = false
/// handles adding conditions to source .cpprc file from .bashrc and .profile
function setupCppInProfile() {
export function setupCppInProfile() {
if (setupCppInProfile_called) {
return
}

View File

@ -3,6 +3,9 @@ import { InstallationInfo } from "./setupBin"
import { execSudo } from "../exec/sudo"
import { info } from "@actions/core"
import { warning } from "../io/io"
import { isGitHubCI } from "../env/isci"
import { cpprc_path, setupCppInProfile } from "../env/addEnv"
import { appendFileSync } from "fs"
let didUpdate: boolean = false
let didInit: boolean = false
@ -70,5 +73,13 @@ export async function setupAptPack(
}
export function updateAptAlternatives(name: string, path: string) {
return execSudo("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, "10"])
if (isGitHubCI()) {
return execSudo("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, "10"])
} else {
setupCppInProfile()
return appendFileSync(
cpprc_path,
`\nif [ $UID -eq 0 ]; then update-alternatives --install /usr/bin/${name} ${name} ${path} 10; fi\n`
)
}
}