From 8c81b8d0624c5aa71acbdce66d0e8bd1bb3ad2d8 Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Thu, 6 Sep 2018 16:46:49 +0300 Subject: [PATCH] Gem (fix #65) --- README.md | 1 + src/generic.rs | 22 ++++++++++++++++++++++ src/main.rs | 4 ++++ 3 files changed, 27 insertions(+) diff --git a/README.md b/README.md index 5ba4e5f1..534fe298 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Just run `topgrade`. It will run the following steps: * Run `yarn global update` if yarn is installed. * Run `npm update -g` if NPM is installed and `npm root -g` is a path inside your home directory. * Upgrade Atom packages +* Run `gem upgrade --user-install` if `/.gem` exists * *Linux*: Update Flatpak packages * *Linux*: Update snap packages * *Linux*: Run [fwupdmgr](https://github.com/hughsie/fwupd) to show firmware upgrade. (View diff --git a/src/generic.rs b/src/generic.rs index 00dac048..598d1b4d 100644 --- a/src/generic.rs +++ b/src/generic.rs @@ -27,6 +27,28 @@ pub fn run_cargo_update(base_dirs: &BaseDirs, terminal: &mut Terminal, dry_run: None } +#[must_use] +pub fn run_gem(base_dirs: &BaseDirs, terminal: &mut Terminal, dry_run: bool) -> Option<(&'static str, bool)> { + if let Some(gem) = utils::which("gem") { + if base_dirs.home_dir().join(".gem").exists() { + terminal.print_separator("RubyGems"); + + let success = || -> Result<(), Error> { + Executor::new(&gem, dry_run) + .args(&["update", "--user-install"]) + .spawn()? + .wait()? + .check()?; + + Ok(()) + }().is_ok(); + + return Some(("RubyGems", success)); + } + } + None +} + #[must_use] pub fn run_emacs(base_dirs: &BaseDirs, terminal: &mut Terminal, dry_run: bool) -> Option<(&'static str, bool)> { if let Some(emacs) = utils::which("emacs") { diff --git a/src/main.rs b/src/main.rs index b7aae42d..00e830d8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -223,6 +223,10 @@ fn run() -> Result<(), Error> { |terminal| generic::run_apm(terminal, opt.dry_run), &mut terminal, )); + report.push_result(execute( + |terminal| generic::run_gem(&base_dirs, terminal, opt.dry_run), + &mut terminal, + )); #[cfg(target_os = "linux")] {