Rustup should update itself when appropriate (fixes #30)

This commit is contained in:
Roey Darwish Dror
2018-06-25 22:35:58 +03:00
parent ef3c4897bc
commit a6abb7c6bc
2 changed files with 11 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ Just run `topgrade`. It will run the following steps:
* Custom defined paths
* *Unix*: Run [zplug](https://github.com/zplug/zplug) update
* *Unix*: Upgrade tmux plugins with [TPM](https://github.com/tmux-plugins/tpm)
* Update Rustup by running `rustup update`. This will also attempt to run `rustup self update` when Rustup is installed inside the home directory.
* Run Cargo [install-update](https://github.com/nabijaczleweli/cargo-update)
* Upgrade Emacs packages
* Upgrade Vim packages. Works with the following plugin frameworks:

View File

@@ -1,7 +1,9 @@
use super::utils::Check;
use failure;
use std::env::home_dir;
use std::path::PathBuf;
use std::process::Command;
use utils::is_ancestor;
const EMACS_UPGRADE: &str = include_str!("emacs.el");
@@ -111,6 +113,14 @@ pub fn run_fwupdmgr(fwupdmgr: &PathBuf) -> Result<(), failure::Error> {
}
pub fn run_rustup(rustup: &PathBuf) -> Result<(), failure::Error> {
if is_ancestor(&home_dir().unwrap(), &rustup) {
Command::new(rustup)
.args(&["self", "update"])
.spawn()?
.wait()?
.check()?;
}
Command::new(rustup).arg("update").spawn()?.wait()?.check()?;
Ok(())