fix(sudo): use require_sudo for windows commands

This commit is contained in:
Andre Toerien
2025-09-26 21:27:18 +02:00
committed by Gideon
parent a2afdb821f
commit 791993795a
3 changed files with 10 additions and 13 deletions

View File

@@ -82,10 +82,11 @@ impl Powershell {
cmd: &str,
use_sudo: bool,
) -> Result<impl CommandExt + 'a> {
// if use_sudo and sudo is available, use it, otherwise run directly
let mut command = match ctx.sudo() {
Some(sudo) if use_sudo => sudo.execute(ctx, &self.path)?,
_ => ctx.execute(&self.path),
let mut command = if use_sudo {
let sudo = ctx.require_sudo()?;
sudo.execute(ctx, &self.path)?
} else {
ctx.execute(&self.path)
};
#[cfg(windows)]