2018-08-19 14:45:23 +03:00
|
|
|
use super::terminal::Terminal;
|
2018-08-22 22:01:06 +03:00
|
|
|
use super::utils::{self, which, Check};
|
2018-06-28 12:16:54 +03:00
|
|
|
use failure;
|
2018-08-22 22:01:06 +03:00
|
|
|
use std::path::PathBuf;
|
2018-06-28 12:16:54 +03:00
|
|
|
use std::process::Command;
|
|
|
|
|
|
2018-08-19 14:45:23 +03:00
|
|
|
#[must_use]
|
|
|
|
|
pub fn run_chocolatey(terminal: &mut Terminal) -> Option<(&'static str, bool)> {
|
|
|
|
|
if let Some(choco) = utils::which("choco") {
|
|
|
|
|
terminal.print_separator("Chocolatey");
|
2018-06-28 12:16:54 +03:00
|
|
|
|
2018-08-19 14:45:23 +03:00
|
|
|
let success = || -> Result<(), failure::Error> {
|
|
|
|
|
Command::new(&choco).args(&["upgrade", "all"]).spawn()?.wait()?.check()?;
|
|
|
|
|
Ok(())
|
|
|
|
|
}().is_ok();
|
|
|
|
|
|
|
|
|
|
return Some(("Chocolatey", success));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
None
|
2018-06-28 12:16:54 +03:00
|
|
|
}
|
2018-08-22 22:01:06 +03:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|