Skip to content

Commit a527dd9

Browse files
fix: Fix remove command to work properly with packages
Previously removing a mod would remove only the first sub-mod found of the given package. Now it will properly find the root of the package and remove that instead.
1 parent 4cec48c commit a527dd9

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/core/commands/remove.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
use std::fs;
22

33
use anyhow::Result;
4+
use owo_colors::OwoColorize;
45
use tracing::debug;
56

6-
use crate::{config::CONFIG, model::ModName};
7-
use thermite::prelude::*;
7+
use crate::{config::CONFIG, model::ModName, utils::find_package_roots};
88

99
pub fn remove(mods: Vec<ModName>) -> Result<()> {
10-
let locals = find_mods(CONFIG.install_dir()?)?;
10+
let locals = find_package_roots(CONFIG.install_dir()?)?;
1111

1212
for m in mods {
1313
debug!("Searching for '{m}'");
1414
if let Some(installed) = locals.iter().find(|v| {
15-
let local = ModName::from(*v);
15+
let Ok(local) = ModName::try_from(v.as_path()) else {
16+
return false;
17+
};
18+
1619
debug!("Testing '{local}'");
1720
m.name.to_lowercase() == local.name.to_lowercase()
1821
&& m.author.to_lowercase() == local.author.to_lowercase()
1922
}) {
20-
println!("Removing package '{}'", m);
21-
fs::remove_dir_all(&installed.path)?;
23+
println!("Removing package '{}'", m.bright_cyan());
24+
debug!("Removing mod {installed:?}");
25+
fs::remove_dir_all(installed)?;
2226
}
2327
}
2428

0 commit comments

Comments
 (0)