diff --git a/crates/packager/src/config/mod.rs b/crates/packager/src/config/mod.rs index cf394eda..04348c41 100644 --- a/crates/packager/src/config/mod.rs +++ b/crates/packager/src/config/mod.rs @@ -1659,15 +1659,12 @@ impl Config { let Some(patterns) = &self.icons else { return Ok(None); }; - let mut paths = Vec::new(); - for pattern in patterns { for icon_path in glob::glob(pattern)? { paths.push(icon_path?); } } - Ok(Some(paths)) } } @@ -1754,8 +1751,8 @@ impl Config { } #[allow(unused)] - pub(crate) fn find_ico(&self) -> Option { - self.icons + pub(crate) fn find_ico(&self) -> crate::Result> { + let icon = self.icons()? .as_ref() .and_then(|icons| { icons @@ -1767,7 +1764,8 @@ impl Config { }) }) }) - .map(PathBuf::from) + .map(PathBuf::from); + Ok(icon) } #[allow(unused)] diff --git a/crates/packager/src/package/wix/mod.rs b/crates/packager/src/package/wix/mod.rs index 76cf20ca..be9a2be2 100644 --- a/crates/packager/src/package/wix/mod.rs +++ b/crates/packager/src/package/wix/mod.rs @@ -519,7 +519,7 @@ fn build_wix_app_installer(ctx: &Context, wix_path: &Path) -> crate::Result>(path: P) -> bool { pub fn create_icns_file(out_dir: &Path, config: &crate::Config) -> crate::Result> { use image::GenericImageView; - if config.icons.as_ref().map(|i| i.len()).unwrap_or_default() == 0 { + let icons = config.icons()?; + if icons.as_ref().map(|i| i.len()).unwrap_or_default() == 0 { return Ok(None); } // If one of the icon files is already an ICNS file, just use that. - if let Some(icons) = &config.icons { + if let Some(icons) = icons { std::fs::create_dir_all(out_dir)?; - for icon_path in icons { - let icon_path = PathBuf::from(icon_path); if icon_path.extension() == Some(std::ffi::OsStr::new("icns")) { let dest_path = out_dir.join( icon_path @@ -330,8 +329,8 @@ pub fn create_icns_file(out_dir: &Path, config: &crate::Config) -> crate::Result } let mut images_to_resize: Vec<(image::DynamicImage, u32, u32)> = vec![]; - if let Some(icons) = &config.icons { - for icon_path in icons { + if let Some(icons) = config.icons()? { + for icon_path in &icons { let icon = image::open(icon_path)?; let density = if is_retina(icon_path) { 2 } else { 1 }; let (w, h) = icon.dimensions();