Automatically detect gsudo (#469)

This commit is contained in:
Roey Darwish Dror
2020-07-10 11:21:19 +03:00
committed by GitHub
parent 69b9c4b24c
commit 065565240e
5 changed files with 15 additions and 38 deletions

View File

@@ -3,26 +3,22 @@ use crate::execution_context::ExecutionContext;
use crate::executor::{CommandExt, RunType};
use crate::powershell;
use crate::terminal::print_separator;
use crate::utils::{require, which};
use crate::utils::require;
use anyhow::Result;
use std::process::Command;
pub fn run_chocolatey(ctx: &ExecutionContext) -> Result<()> {
let choco = require("choco")?;
let yes = ctx.config().yes();
let use_gsudo = ctx.config().use_gsudo_with_choco();
print_separator("Chocolatey");
let mut cmd = choco;
let mut cmd = &choco;
let mut args = vec!["upgrade", "all"];
if use_gsudo {
let gsudo = which("gsudo");
if let Some(gsudo) = gsudo {
cmd = gsudo;
args = vec!["choco", "upgrade", "all"];
}
if let Some(sudo) = ctx.sudo() {
cmd = sudo;
args.insert(0, "choco");
}
let mut command = ctx.run_type().execute(&cmd);