Powershell module update (fix #41)
This commit is contained in:
@@ -92,6 +92,12 @@ fn run() -> Result<(), Error> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
let powershell = windows::Powershell::new();
|
||||
|
||||
#[cfg(windows)]
|
||||
report(&mut reports, powershell.update_modules(&mut terminal));
|
||||
|
||||
if !(matches.is_present("no_system")) {
|
||||
#[cfg(target_os = "linux")]
|
||||
report(&mut reports, linux::upgrade(&sudo, &mut terminal));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use super::terminal::Terminal;
|
||||
use super::utils::{self, Check};
|
||||
use super::utils::{self, which, Check};
|
||||
use failure;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
#[must_use]
|
||||
@@ -18,3 +19,31 @@ pub fn run_chocolatey(terminal: &mut Terminal) -> Option<(&'static str, bool)> {
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
pub struct Powershell {
|
||||
path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl Powershell {
|
||||
pub fn new() -> Self {
|
||||
Powershell {
|
||||
path: which("powershell"),
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn update_modules(&self, terminal: &mut Terminal) -> Option<(&'static str, bool)> {
|
||||
if let Some(powershell) = &self.path {
|
||||
terminal.print_separator("Powershell Module Update");
|
||||
|
||||
let success = || -> Result<(), failure::Error> {
|
||||
Command::new(&powershell).arg("Update-Module").spawn()?.wait()?.check()?;
|
||||
Ok(())
|
||||
}().is_ok();
|
||||
|
||||
return Some(("Powershell Module Update", success));
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user