Skip to content

Commit

Permalink
Only show restart terminal hint after self-install when necessary (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptibell authored Jun 15, 2024
1 parent 0b4a1f4 commit d4a985d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
13 changes: 8 additions & 5 deletions lib/system/env/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub async fn add_to_path(home: &Home) -> RokitResult<bool> {

// Add the path to known shell profiles
let added_any = if let Some(home_dir) = dirs::home_dir() {
Shell::ALL
let futs = Shell::ALL
.iter()
.map(|shell| {
let shell_env_path = home_dir.join(shell.env_file_path());
Expand All @@ -44,11 +44,14 @@ pub async fn add_to_path(home: &Home) -> RokitResult<bool> {
shell_should_create,
)
})
.collect::<FuturesUnordered<_>>()
.collect::<Vec<_>>()
.collect::<FuturesUnordered<_>>();
// NOTE: append_to_shell_file returns `true` if the line was added,
// we need to preserve this information, but also not fail if
// any of the file operations do, so we unwrap_or_default
futs.collect::<Vec<_>>()
.await
.iter()
.any(Result::is_ok)
.into_iter()
.any(Result::unwrap_or_default)
} else {
false
};
Expand Down
9 changes: 3 additions & 6 deletions lib/system/env/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ pub async fn add_to_path(home: &Home) -> RokitResult<bool> {
let env = key.create_subkey("Environment")?.0;
let path = env.get_value::<String, _>("PATH")?;

let path_already_exists = path.split(';').any(|entry| {
Path::new(entry)
.canonicalize()
.map(|p| p == dir)
.unwrap_or_default()
});
let path_already_exists = path
.split(';')
.any(|entry| Path::new(entry).canonicalize().is_ok_and(|p| p == dir));

if path_already_exists {
Ok::<_, RokitError>(false)
Expand Down

0 comments on commit d4a985d

Please sign in to comment.