mirror of https://github.com/aminya/setup-cpp
perf: make updateAlternatives async
This commit is contained in:
parent
ebd90dd38d
commit
b625cd0632
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -4,8 +4,10 @@ import { execRootSync } from "admina"
|
||||||
import { info } from "@actions/core"
|
import { info } from "@actions/core"
|
||||||
import ciDetect from "@npmcli/ci-detect"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { addEnv, cpprc_path, setupCppInProfile } from "../env/addEnv"
|
import { addEnv, cpprc_path, setupCppInProfile } from "../env/addEnv"
|
||||||
import { appendFileSync, existsSync } from "fs"
|
|
||||||
import which from "which"
|
import which from "which"
|
||||||
|
import { pathExists } from "path-exists"
|
||||||
|
import { promises as fsPromises } from "fs"
|
||||||
|
const { appendFile } = fsPromises
|
||||||
|
|
||||||
let didUpdate: boolean = false
|
let didUpdate: boolean = false
|
||||||
let didInit: boolean = false
|
let didInit: boolean = false
|
||||||
|
@ -123,12 +125,12 @@ export async function addAptKeyViaDownload(name: string, url: string) {
|
||||||
return fileName
|
return fileName
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateAptAlternatives(name: string, path: string) {
|
export async function updateAptAlternatives(name: string, path: string) {
|
||||||
if (ciDetect() === "github-actions") {
|
if (ciDetect() === "github-actions") {
|
||||||
return execRootSync("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, "40"])
|
return execRootSync("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, "40"])
|
||||||
} else {
|
} else {
|
||||||
setupCppInProfile()
|
await setupCppInProfile()
|
||||||
return appendFileSync(
|
return appendFile(
|
||||||
cpprc_path,
|
cpprc_path,
|
||||||
`\nif [ $UID -eq 0 ]; then update-alternatives --install /usr/bin/${name} ${name} ${path} 40; fi\n`
|
`\nif [ $UID -eq 0 ]; then update-alternatives --install /usr/bin/${name} ${name} ${path} 40; fi\n`
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue