Skip to content

Commit

Permalink
fix(PATH): add ability to concat PATH on any platform (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
beetcb authored Dec 4, 2021
1 parent 270e9cb commit 8f7e820
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ use std::process::{exit, Command};

// Get PATH env and join it with bin_dir
fn get_path_env(bin_dirs: Vec<PathBuf>) -> String {
let mut path = env::var("PATH").unwrap_or_default();
for dir in bin_dirs {
path.push_str(":");
path.push_str(dir.to_str().unwrap());
}
path
let path = PathBuf::from(env::var("PATH").unwrap_or_default());
env::join_paths(
bin_dirs
.iter()
.chain(env::split_paths(&path).collect::<Vec<PathBuf>>().iter()),
)
.ok()
.unwrap()
.into_string()
.unwrap()
}

// A function to find the closest file
Expand Down

0 comments on commit 8f7e820

Please sign in to comment.