Skip to content

Commit

Permalink
fix: shortcut filename (#1136)
Browse files Browse the repository at this point in the history
Co-authored-by: Wolf Vollprecht <w.vollprecht@gmail.com>
Co-authored-by: Ruben Arts <ruben.arts@hotmail.com>
  • Loading branch information
3 people authored Mar 4, 2025
1 parent 3f484ae commit 41506fa
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions crates/rattler_menuinst/src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,6 @@ pub struct Directories {
windows_terminal_settings_files: Vec<PathBuf>,
}

fn shortcut_filename(name: &str, env_name: Option<&String>, ext: Option<&str>) -> String {
let env = if let Some(env_name) = env_name {
format!(" ({env_name})")
} else {
"".to_string()
};

let ext = ext.unwrap_or("lnk");
format!("{name}{env}{ext}")
}

/// On Windows we can create shortcuts in several places:
/// - Start Menu
/// - Desktop
Expand Down Expand Up @@ -138,18 +127,13 @@ impl WindowsMenu {
) -> Self {
let name = command.name.resolve(Environment::Base, placeholders);

let shortcut_name = shortcut_filename(
&name,
placeholders.as_ref().get("ENV_NAME"),
Some(SHORTCUT_EXTENSION),
);
let shortcut_name = format!("{name}.{SHORTCUT_EXTENSION}");

let location = directories
.start_menu
.join(&shortcut_name)
.with_extension(SHORTCUT_EXTENSION);

// self.menu.start_menu_location / self._shortcut_filename()
Self {
prefix: prefix.to_path_buf(),
name,
Expand Down Expand Up @@ -194,10 +178,6 @@ impl WindowsMenu {
Ok(lines.join("\n"))
}

fn shortcut_filename(&self, ext: Option<&str>) -> String {
shortcut_filename(&self.name, self.placeholders.as_ref().get("ENV_NAME"), ext)
}

fn write_script(&self, path: &Path) -> Result<(), MenuInstError> {
if let Some(parent) = path.parent() {
fs::create_dir_all(parent)?;
Expand All @@ -210,9 +190,7 @@ impl WindowsMenu {
}

fn path_for_script(&self) -> PathBuf {
self.prefix
.join("Menu")
.join(self.shortcut_filename(Some("bat")))
self.prefix.join("Menu").join(format!("{}.bat", &self.name))
}

fn build_command(&self, with_arg1: bool) -> Result<Vec<String>, MenuInstError> {
Expand Down

0 comments on commit 41506fa

Please sign in to comment.