mirror of https://github.com/aminya/setup-cpp
fix: use sudo for pip if available
This commit is contained in:
parent
53b53fef98
commit
cd775009da
|
@ -5,6 +5,7 @@ import { addPath, info } from "@actions/core"
|
|||
import { setupPython } from "../../python/python"
|
||||
import { isBinUptoDate } from "./version"
|
||||
import { join } from "path"
|
||||
import { mightSudo } from "./sudo"
|
||||
|
||||
let pip: string | undefined
|
||||
|
||||
|
@ -24,7 +25,10 @@ export async function setupPipPack(name: string, version?: string) {
|
|||
}
|
||||
}
|
||||
|
||||
const exit = await exec(pip, ["install", version !== undefined && version !== "" ? `${name}==${version}` : name])
|
||||
const exit = await exec(mightSudo(pip), [
|
||||
"install",
|
||||
version !== undefined && version !== "" ? `${name}==${version}` : name,
|
||||
])
|
||||
if (exit !== 0) {
|
||||
throw new Error(`Failed to install ${name} ${version}`)
|
||||
}
|
||||
|
|
|
@ -10,8 +10,12 @@ export function isRoot(): boolean {
|
|||
}
|
||||
|
||||
export function mightSudo(command: string) {
|
||||
if (isRoot()) {
|
||||
return `sudo ${command}`
|
||||
try {
|
||||
if (isRoot()) {
|
||||
return `sudo ${command}`
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
return command
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue