From 35e805478d33fb794ccd4670824f443a81e59219 Mon Sep 17 00:00:00 2001 From: Roland Schaer Date: Mon, 15 Apr 2024 17:27:15 -0300 Subject: [PATCH] fix: go backend naming inconsistency (in mise ls and mise prune) (#1905) --- src/cli/args/forge_arg.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cli/args/forge_arg.rs b/src/cli/args/forge_arg.rs index 44e7f6092..450aa9601 100644 --- a/src/cli/args/forge_arg.rs +++ b/src/cli/args/forge_arg.rs @@ -49,7 +49,18 @@ impl ForgeArg { } pub fn from_pathname(name: &str) -> Self { - let fa_name = name.replacen('-', ":", 1); + let mut fa_name = name.replacen('-', ":", 1); + let forge_type = name.split('-').next().unwrap_or_default(); + // Go packages cannot have dashes in their name. + // - Simply replace dashes with slashes + if ForgeType::Go.as_ref() == forge_type { + fa_name = fa_name.replace('-', "/"); + } + // NPM packages can have dashes and slashes in their name. + // - If scoped, replace first dash after the @ with a slash. Will not work for scopes using dashes + if ForgeType::Npm.as_ref() == forge_type && fa_name.contains('@') { + fa_name = fa_name.replacen('-', "/", 1); + } ForgeArg::from_str(&fa_name).unwrap() } }