Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Nov 10, 2024
1 parent 81a4409 commit 4636f49
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
7 changes: 5 additions & 2 deletions crates/rattler_menuinst/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn install_menuitems(
#[cfg(target_os = "macos")]

Check warning on line 62 in crates/rattler_menuinst/src/lib.rs

View workflow job for this annotation

GitHub Actions / Format and Lint

Diff in /home/runner/work/rattler/rattler/crates/rattler_menuinst/src/lib.rs
if let Some(macos_item) = item.platforms.osx {
let command = item.command.merge(macos_item.base);
macos::install_menu_item(prefix, macos_item.specific, command, MenuMode::System)?;
macos::install_menu_item(prefix, macos_item.specific, command, &placeholders, MenuMode::System)?;
}
} else if platform.is_windows() {
#[cfg(target_os = "windows")]
Expand Down Expand Up @@ -95,6 +95,9 @@ pub mod test {

#[test]
fn test_install_menu_item() {
if std::env::var("INSTALL_MENU_ITEM").is_err() {
return;
}

Check warning on line 100 in crates/rattler_menuinst/src/lib.rs

View workflow job for this annotation

GitHub Actions / Format and Lint

Diff in /home/runner/work/rattler/rattler/crates/rattler_menuinst/src/lib.rs
println!("Running test_install_menu_item");
let test_data = crate::test::test_data();
let schema_path = test_data.join("/Users/wolfv/Programs/rattler/.prefix/Menu/napari-menu.json");
Expand All @@ -104,6 +107,6 @@ pub mod test {
println!("prefix: {:?}", prefix);
let platform = Platform::OsxArm64;

install_menuitems(&schema_path, &prefix, &prefix, &platform).unwrap();
install_menuitems(&schema_path, &prefix, &prefix, platform).unwrap();
}
}
11 changes: 7 additions & 4 deletions crates/rattler_menuinst/src/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use fs_err::File;
use plist::Value;

Check warning on line 11 in crates/rattler_menuinst/src/macos.rs

View workflow job for this annotation

GitHub Actions / Format and Lint

Diff in /home/runner/work/rattler/rattler/crates/rattler_menuinst/src/macos.rs

use crate::{
schema::{MacOS, MenuItemCommand},
slugify, utils, MenuInstError, MenuMode,
render::BaseMenuItemPlaceholders, schema::{MacOS, MenuItemCommand}, slugify, utils, MenuInstError, MenuMode
};

pub struct MacOSMenu {
Expand Down Expand Up @@ -74,11 +73,12 @@ impl MacOSMenu {
item: MacOS,
command: MenuItemCommand,
directories: Directories,
placeholders: &BaseMenuItemPlaceholders,
) -> Self {
Self {
name: command
.name
.resolve(crate::schema::Environment::Base)
.resolve(crate::schema::Environment::Base, placeholders)
.to_string(),
prefix: prefix.to_path_buf(),
item,
Expand Down Expand Up @@ -600,14 +600,17 @@ impl MacOSMenu {
}

pub(crate) fn install_menu_item(
prefix: &Path,
macos_item: MacOS,
command: MenuItemCommand,
placeholders: &BaseMenuItemPlaceholders,
menu_mode: MenuMode,
) -> Result<(), MenuInstError> {
let bundle_name = format!("{}.app", macos_item.cf_bundle_name.as_ref().unwrap());
let directories = Directories::new(menu_mode, &bundle_name);

println!("Installing menu item for {bundle_name}");
let menu = MacOSMenu::new(prefix, macos_item, command, directories);
let menu = MacOSMenu::new(prefix, macos_item, command, directories, placeholders);
menu.install()
}

Expand Down
3 changes: 0 additions & 3 deletions crates/rattler_menuinst/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use rattler_conda_types::Platform;
use std::{collections::HashMap, path::Path};
use serde::{Deserialize, Serialize};
use crate::schema::MenuInstSchema;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(transparent)]
Expand Down Expand Up @@ -118,8 +117,6 @@ fn replace_placeholders(mut text: String, replacements: &HashMap<String, String>

#[cfg(test)]
mod test {
use std::path::Path;

// use crate::render::render;

// #[test]
Expand Down
3 changes: 1 addition & 2 deletions crates/rattler_menuinst/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ pub struct MenuInstSchema {

Check warning on line 263 in crates/rattler_menuinst/src/schema.rs

View workflow job for this annotation

GitHub Actions / Format and Lint

Diff in /home/runner/work/rattler/rattler/crates/rattler_menuinst/src/schema.rs
#[cfg(test)]
mod test {
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use rattler_conda_types::Platform;
use crate::render::BaseMenuItemPlaceholders;
Expand Down Expand Up @@ -316,7 +315,7 @@ mod test {
);

assert_eq!(
command.name.resolve(super::Environment::Base),
command.name.resolve(super::Environment::Base, &placeholders),
"Spyder 6 ({{ DISTRIBUTION_NAME }})"
);

Expand Down

0 comments on commit 4636f49

Please sign in to comment.