Skip to content

Commit

Permalink
Fix PATH variable splitting on Windows (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptibell committed Jul 17, 2024
1 parent 8bae269 commit 467b94f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/system/env/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::{env::var, path::MAIN_SEPARATOR_STR};
use std::{
env::{split_paths, var_os},
path::MAIN_SEPARATOR_STR,
};

use crate::{result::RokitResult, storage::Home};

Expand Down Expand Up @@ -39,7 +42,7 @@ pub async fn add_to_path(home: &Home) -> RokitResult<bool> {
#[must_use]
pub fn exists_in_path(_home: &Home) -> bool {
let pattern = format!("rokit{MAIN_SEPARATOR_STR}bin");
var("PATH")
.map(|path| path.split(':').any(|item| item.ends_with(&pattern)))
.unwrap_or(false)
var_os("PATH").map_or(false, |path| {
split_paths(&path).any(|item| item.ends_with(&pattern))
})
}

0 comments on commit 467b94f

Please sign in to comment.