mirror of https://github.com/aminya/setup-cpp
feat: add sudo utils
This commit is contained in:
parent
9702fd9926
commit
8ab3e55ee8
|
@ -0,0 +1,17 @@
|
||||||
|
let _issudo: boolean | undefined = undefined
|
||||||
|
|
||||||
|
export function isRoot(): boolean {
|
||||||
|
if (_issudo !== undefined) {
|
||||||
|
return _issudo
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions, @typescript-eslint/no-unnecessary-condition
|
||||||
|
_issudo = Boolean(process.env.CI) || process.getuid?.() === 0
|
||||||
|
return _issudo
|
||||||
|
}
|
||||||
|
|
||||||
|
export function mightSudo(command: string) {
|
||||||
|
if (isRoot()) {
|
||||||
|
return `sudo ${command}`
|
||||||
|
}
|
||||||
|
return command
|
||||||
|
}
|
Loading…
Reference in New Issue