From abc6a8065b5ff92d65c4eb2c21e0b95b937cf393 Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Wed, 15 Jul 2020 08:47:15 +0300 Subject: [PATCH] Support yes flags for Powershell --- src/main.rs | 2 +- src/steps/powershell.rs | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index c8d874e5..7bf97bb3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -223,7 +223,7 @@ fn run() -> Result<()> { if should_run_powershell { runner.execute(Step::Powershell, "Powershell Modules Update", || { - powershell.update_modules(run_type) + powershell.update_modules(&ctx) })?; } diff --git a/src/steps/powershell.rs b/src/steps/powershell.rs index c6e1b903..3382e492 100644 --- a/src/steps/powershell.rs +++ b/src/steps/powershell.rs @@ -1,6 +1,6 @@ #[cfg(windows)] use crate::execution_context::ExecutionContext; -use crate::executor::{CommandExt, RunType}; +use crate::executor::CommandExt; use crate::terminal::{is_dumb, print_separator}; use crate::utils::{require_option, which, PathExt}; use anyhow::Result; @@ -53,15 +53,19 @@ impl Powershell { self.profile.as_ref() } - pub fn update_modules(&self, run_type: RunType) -> Result<()> { + pub fn update_modules(&self, ctx: &ExecutionContext) -> Result<()> { let powershell = require_option(self.path.as_ref())?; print_separator("Powershell Modules Update"); + + let cmd = if ctx.config().yes() { + "Update-Module -AcceptLicense -Force" + } else { + "Update-Module" + }; + println!("Updating modules..."); - run_type - .execute(&powershell) - .args(&["-Command", "Update-Module"]) - .check_run() + ctx.run_type().execute(&powershell).args(&["-Command", cmd]).check_run() } #[cfg(windows)]