Skip to content

Commit

Permalink
Fix: rm/uninstall not working when 'v' is missing for neovim versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
matdexir committed Jul 14, 2024
1 parent b1b335b commit fa95784
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/handlers/uninstall_handler.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
use crate::{
config::Config,
helpers::{self, directories},
};
use anyhow::{anyhow, Result};
use dialoguer::{
console::{style, Term},
theme::ColorfulTheme,
Confirm, MultiSelect,
};
use regex::Regex;
use reqwest::Client;
use tokio::fs;
use tracing::{info, warn};

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

/// Starts the uninstall process.
///
/// This function creates a new HTTP client, determines the version to uninstall, checks if the version is currently in use, and if not, removes the version's directory.
Expand Down Expand Up @@ -60,7 +60,13 @@ pub async fn start(version: Option<&str>, config: Config) -> Result<()> {
Err(error) => return Err(anyhow!(error)),
};

let path = downloads_dir.join(&version.non_parsed_string);
let version_regex = Regex::new(r"^[0-9]+\.[0-9]+\.[0-9]+$")?;
let path = if version_regex.is_match(&version.non_parsed_string) {
let intermediate = format!("v{}", &version.non_parsed_string);
downloads_dir.join(intermediate)
} else {
downloads_dir.join(&version.non_parsed_string)
};

fs::remove_dir_all(path).await?;
info!(
Expand Down

0 comments on commit fa95784

Please sign in to comment.