Skip to content

Commit

Permalink
add: remove nvim-bin path from $PATH on erase command
Browse files Browse the repository at this point in the history
  • Loading branch information
MordechaiHadad committed Nov 5, 2024
1 parent 533acf5 commit acb26c9
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/handlers/erase_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{anyhow, Result};
use tokio::fs;
use tracing::info;

use crate::{config::Config, helpers::directories};
use crate::{config::Config, helpers::directories::{self, get_downloads_directory}};

Check warning on line 5 in src/handlers/erase_handler.rs

View workflow job for this annotation

GitHub Actions / check (windows-latest)

unused import: `get_downloads_directory`

Check warning on line 5 in src/handlers/erase_handler.rs

View workflow job for this annotation

GitHub Actions / check (windows-latest)

unused import: `get_downloads_directory`

Check failure on line 5 in src/handlers/erase_handler.rs

View workflow job for this annotation

GitHub Actions / clippy (windows-latest)

unused import: `get_downloads_directory`

Check failure on line 5 in src/handlers/erase_handler.rs

View workflow job for this annotation

GitHub Actions / clippy (windows-latest)

unused import: `get_downloads_directory`

Check warning on line 5 in src/handlers/erase_handler.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `get_downloads_directory`

Check warning on line 5 in src/handlers/erase_handler.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `get_downloads_directory`

/// Starts the erase process based on the provided `Config`.
///
Expand Down Expand Up @@ -74,7 +74,28 @@ pub async fn start(config: Config) -> Result<()> {

info!("Successfully removed neovim's installation PATH from registry");
}
} else {
use what_the_path::shell::Shell;

let shell = Shell::detect_by_shell_var()?;

match shell {
Shell::Fish(fish) => {
let files = fish.get_rcfiles()?;
let fish_file = files[0].join("bob.fish");
if !fish_file.exists() { return Ok(()) }
fs::remove_file(fish_file).await?;
},
shell => {
let files = shell.get_rcfiles()?;
let downloads_dir = get_downloads_directory(&config).await?;
let env_path = downloads_dir.join("env/env.sh");
let source_string = format!(". \"{}\"", env_path.display());
for file in files {
what_the_path::shell::remove_from_rcfile(file, &source_string)?;
}
}
}
}
}

Expand Down

0 comments on commit acb26c9

Please sign in to comment.