Powershell module update (fix #41)
This commit is contained in:
@@ -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