2018-07-07 09:18:53 +03:00
|
|
|
use super::utils::{Check, PathExt};
|
|
|
|
|
use directories::BaseDirs;
|
2018-06-06 15:32:38 +03:00
|
|
|
use failure;
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
|
|
const EMACS_UPGRADE: &str = include_str!("emacs.el");
|
|
|
|
|
|
|
|
|
|
pub fn run_cargo_update(cargo_update: &PathBuf) -> Result<(), failure::Error> {
|
|
|
|
|
Command::new(&cargo_update)
|
2018-06-11 15:45:26 +03:00
|
|
|
.args(&["install-update", "--git", "--all"])
|
2018-06-06 15:32:38 +03:00
|
|
|
.spawn()?
|
|
|
|
|
.wait()?
|
|
|
|
|
.check()?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn run_emacs(emacs: &PathBuf, init: &PathBuf) -> Result<(), failure::Error> {
|
|
|
|
|
Command::new(&emacs)
|
2018-07-03 14:33:48 +03:00
|
|
|
.args(&["--batch", "-l", init.to_str().unwrap(), "--eval", EMACS_UPGRADE])
|
2018-06-06 15:32:38 +03:00
|
|
|
.spawn()?
|
|
|
|
|
.wait()?
|
|
|
|
|
.check()?;
|
2018-06-07 08:51:16 +03:00
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-06 15:32:38 +03:00
|
|
|
pub fn run_apm(apm: &PathBuf) -> Result<(), failure::Error> {
|
|
|
|
|
Command::new(&apm)
|
|
|
|
|
.args(&["upgrade", "--confirm=false"])
|
|
|
|
|
.spawn()?
|
|
|
|
|
.wait()?
|
|
|
|
|
.check()?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-07 09:18:53 +03:00
|
|
|
pub fn run_rustup(rustup: &PathBuf, base_dirs: &BaseDirs) -> Result<(), failure::Error> {
|
|
|
|
|
if rustup.is_descendant_of(base_dirs.home_dir()) {
|
2018-07-03 14:33:48 +03:00
|
|
|
Command::new(rustup).args(&["self", "update"]).spawn()?.wait()?.check()?;
|
2018-06-25 22:35:58 +03:00
|
|
|
}
|
|
|
|
|
|
2018-06-07 22:36:32 +03:00
|
|
|
Command::new(rustup).arg("update").spawn()?.wait()?.check()?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-06 15:32:38 +03:00
|
|
|
pub fn run_homebrew(homebrew: &PathBuf) -> Result<(), failure::Error> {
|
2018-07-03 14:33:48 +03:00
|
|
|
Command::new(&homebrew).arg("update").spawn()?.wait()?.check()?;
|
2018-06-06 15:32:38 +03:00
|
|
|
|
2018-07-03 14:33:48 +03:00
|
|
|
Command::new(&homebrew).arg("upgrade").spawn()?.wait()?.check()?;
|
2018-06-06 15:32:38 +03:00
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-08 18:19:07 +03:00
|
|
|
pub fn run_custom_command(command: &str) -> Result<(), failure::Error> {
|
2018-07-03 14:33:48 +03:00
|
|
|
Command::new("sh").arg("-c").arg(command).spawn()?.wait()?.check()?;
|
2018-06-08 18:19:07 +03:00
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|