fix: check if sudo is installed

This commit is contained in:
Amin Yahyaabadi 2021-09-18 08:54:42 -05:00
parent c9b478842d
commit e898202dcc
3 changed files with 4 additions and 3 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

@ -1,4 +1,5 @@
import execa from "execa"
import which from "which"
let _issudo: boolean | undefined = undefined
@ -7,7 +8,7 @@ export function isRoot(): boolean {
return _issudo
}
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions, @typescript-eslint/no-unnecessary-condition
_issudo = Boolean(process.env.CI) || process.getuid?.() === 0
_issudo = (Boolean(process.env.CI) || process.getuid?.() === 0) && which.sync("sudo", { nothrow: true }) !== null
return _issudo
}