Refactor execSync and spawn calls to include windowsHide option for better compatibility on Windows environments.
This commit is contained in:
1 parent
04cdb75839
commit
1fa05eb2ab
8 files changed
+45
-34
No files matched your search
@@ -63,7 +63,7 @@ function executeElevatedPowerShell(psScriptPath, timeoutMs = 30000) {
|
||||
function isSudoAvailable() {
|
||||
if (IS_WIN) return false;
|
||||
try {
|
||||
execSync("command -v sudo", { stdio: "ignore" });
|
||||
execSync("command -v sudo", { stdio: "ignore", windowsHide: true });
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
@@ -78,8 +78,8 @@ function execWithPassword(command, password) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const useSudo = isSudoAvailable();
|
||||
const child = useSudo
|
||||
? spawn("sudo", ["-S", "sh", "-c", command], { stdio: ["pipe", "pipe", "pipe"] })
|
||||
: spawn("sh", ["-c", command], { stdio: ["ignore", "pipe", "pipe"] });
|
||||
? spawn("sudo", ["-S", "sh", "-c", command], { stdio: ["pipe", "pipe", "pipe"], windowsHide: true })
|
||||
: spawn("sh", ["-c", command], { stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
|
||||
|
||||
let stdout = "";
|
||||
let stderr = "";
|
||||
|
||||
Reference in new issue
Block a user