Skip to content

Commit

Permalink
fix(bundler/macos): clean up .app bundle if only .dmg is enabled taur…
Browse files Browse the repository at this point in the history
  • Loading branch information
fcfangcc committed Jun 2, 2023
1 parent 0ddbb3a commit 60a2fea
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tooling/bundler/src/bundle/macos/dmg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ use std::{
/// Bundles the project.
/// Returns a vector of PathBuf that shows where the DMG was created.
pub fn bundle_project(settings: &Settings, bundles: &[Bundle]) -> crate::Result<Vec<PathBuf>> {
let mut app_bundle_paths = vec![];

// generate the .app bundle if needed
if bundles
.iter()
.filter(|bundle| bundle.package_type == MacOsBundle)
.count()
== 0
{
app::bundle_project(settings)?;
app_bundle_paths = app::bundle_project(settings)?;
}

// get the target path
Expand Down Expand Up @@ -147,6 +149,16 @@ pub fn bundle_project(settings: &Settings, bundles: &[Bundle]) -> crate::Result<

fs::rename(bundle_dir.join(dmg_name), dmg_path.clone())?;

// Clean up .app if only .dmg, .app is directory
for app_bundle_path in app_bundle_paths {
info!(action = "Cleaning"; "{}", app_bundle_path.display());
match app_bundle_path.is_dir() {
true => fs::remove_dir_all(&app_bundle_path),
false => fs::remove_file(&app_bundle_path),
}
.with_context(|| format!("Failed to cleaning the {}", app_bundle_path.display()))?
}

// Sign DMG if needed
if let Some(identity) = &settings.macos().signing_identity {
super::sign::sign(dmg_path.clone(), identity, settings, false)?;
Expand Down

0 comments on commit 60a2fea

Please sign in to comment.