Skip to content

Commit

Permalink
change shortcut filename function to not include env
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Mar 4, 2025
1 parent 1fb3374 commit 655448e
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions crates/rattler_menuinst/src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@ 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()
};

fn shortcut_filename(name: &str, ext: Option<&str>) -> String {
let ext = ext.unwrap_or("lnk");
format!("{name}{env}.{ext}")

Check failure on line 43 in crates/rattler_menuinst/src/windows.rs

View workflow job for this annotation

GitHub Actions / Windows-x86_64

expected value, found macro `env`

Check failure on line 43 in crates/rattler_menuinst/src/windows.rs

View workflow job for this annotation

GitHub Actions / Windows-aarch64

expected value, found macro `env`
}
Expand Down Expand Up @@ -138,18 +132,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 = shortcut_filename(&name, Some(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 +183,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 @@ -212,7 +197,7 @@ impl WindowsMenu {
fn path_for_script(&self) -> PathBuf {
self.prefix
.join("Menu")
.join(self.shortcut_filename(Some("bat")))
.join(shortcut_filename(&self.name, Some("bat")))
}

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

0 comments on commit 655448e

Please sign in to comment.