From d0248385d5faeee6eb4aacfb20eece2889f45a6a Mon Sep 17 00:00:00 2001 From: Eric Mark Martin Date: Tue, 26 Feb 2019 11:53:22 -0800 Subject: [PATCH] refactor(zplug): return PathBuf to .zshrc file --- src/steps/os/unix.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/steps/os/unix.rs b/src/steps/os/unix.rs index a38fd47c..212c1839 100644 --- a/src/steps/os/unix.rs +++ b/src/steps/os/unix.rs @@ -4,22 +4,22 @@ use crate::terminal::print_separator; use crate::utils::{require, which}; use directories::BaseDirs; use std::env; -use std::path::Path; +use std::path::{Path, PathBuf}; use std::process::Command; fn zplug_exists(base_dirs: &BaseDirs) -> bool { env::var("ZPLUG_HOME") .map(|ref zplug_home| Path::new(zplug_home).exists()) - .map(|p| p || base_dirs.home_dir().join("zplug").exists()) .unwrap_or(false) + || base_dirs.home_dir().join("zplug").exists() } -fn get_zshrc(base_dirs: &BaseDirs) -> Result { +fn get_zshrc(base_dirs: &BaseDirs) -> Result { env::var("ZDOTDIR") .map(|ref zdotdir| Path::new(zdotdir).join(".zshrc")) .unwrap_or_else(|_| base_dirs.home_dir().join(".zshrc")) .to_str() - .map(|s| s.to_owned()) + .map(PathBuf::from) .ok_or(()) } @@ -30,7 +30,7 @@ pub fn run_zplug(base_dirs: &BaseDirs, run_type: RunType) -> Option<(&'static st let success = || -> Result<(), Error> { let zshrc = get_zshrc(base_dirs).map_err(|_| Error::from(SkipStep))?; - let cmd = format!("source {} && zplug update", zshrc); + let cmd = format!("source {} && zplug update", zshrc.display()); run_type.execute(zsh).args(&["-c", cmd.as_str()]).check_run()?; Ok(()) }()