From 94c0102885e5e50407a54919afe51e2f7118e767 Mon Sep 17 00:00:00 2001 From: Jonathan Dahan Date: Thu, 5 Sep 2019 02:37:42 -0400 Subject: [PATCH] Add zr support (#216) --- README.md | 1 + src/main.rs | 6 ++++++ src/steps/os/unix.rs | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/README.md b/README.md index 8614da78..439acd3c 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ Just run `topgrade`. It will run the following steps: * ~/.config/i3 * Powershell Profile * Custom defined paths +* **Unix**: Run [zr](https://github.com/jedahan/zr) update * **Unix**: Run [zplug](https://github.com/zplug/zplug) update * **Unix**: Run [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) update * **Unix**: Run [fisher](https://github.com/jorgebucaran/fisher) diff --git a/src/main.rs b/src/main.rs index 587f5f4c..6a8deb7b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -260,6 +260,12 @@ fn run() -> Result<(), Error> { #[cfg(unix)] { + execute( + &mut report, + "zr", + || unix::run_zr(&base_dirs, run_type), + config.no_retry(), + )?; execute( &mut report, "zplug", diff --git a/src/steps/os/unix.rs b/src/steps/os/unix.rs index 434640d1..1bd66009 100644 --- a/src/steps/os/unix.rs +++ b/src/steps/os/unix.rs @@ -7,6 +7,22 @@ use std::env; use std::path::{Path, PathBuf}; use std::process::Command; +pub fn run_zr(base_dirs: &BaseDirs, run_type: RunType) -> Result<(), Error> { + let zsh = require("zsh")?; + + env::var("ZR_HOME") + .map(PathBuf::from) + .unwrap_or_else(|_| base_dirs.home_dir().join(".zr")) + .require()?; + + print_separator("zr"); + + let zshrc = base_dirs.home_dir().join(".zshrc"); + + let cmd = format!("source {} && zr update", zshrc.display()); + run_type.execute(zsh).args(&["-c", cmd.as_str()]).check_run() +} + pub fn run_zplug(base_dirs: &BaseDirs, run_type: RunType) -> Result<(), Error> { let zsh = require("zsh")?;