mirror of https://github.com/aminya/setup-cpp
fix: append update-alternatives to cpprc instead
This commit is contained in:
parent
dea371a1d9
commit
a6e315987a
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue