Refactor execSync and spawn calls to include windowsHide option for better compatibility on Windows environments.

This commit is contained in:
decolua
2026-04-14 11:48:59 +07:00
parent 04cdb75839
commit 1fa05eb2ab
8 changed files with 45 additions and 34 deletions
+3 -3
View File
@@ -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 = "";