Skip to content

Commit

Permalink
Allow missing package.metadata.bundle section
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed May 28, 2024
1 parent fe7d96f commit c500f23
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/bundle/settings.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::category::AppCategory;
use super::common::print_warning;
use clap::ArgMatches;

use cargo_metadata::{Metadata, MetadataCommand};
Expand Down Expand Up @@ -59,7 +60,7 @@ pub enum BuildArtifact {
Example(String),
}

#[derive(Clone, Debug, Deserialize)]
#[derive(Clone, Debug, Default, Deserialize)]
struct BundleSettings {
// General settings:
name: Option<String>,
Expand Down Expand Up @@ -261,7 +262,12 @@ impl Settings {
return Ok((settings, package.clone()));
}
}
bail!("No package in workspace has [package.metadata.bundle] section")
print_warning("No package in workspace has [package.metadata.bundle] section")?;
if let Some(root_package) = metadata.root_package() {
Ok((BundleSettings::default(), root_package.clone()))
} else {
bail!("unable to find root package")
}
}

/// Returns the directory where the bundle should be placed.
Expand Down Expand Up @@ -469,11 +475,11 @@ fn bundle_settings_from_table(
if let Some(bundle_settings) = opt_map.as_ref().and_then(|map| map.get(bundle_name)) {
Ok(bundle_settings.clone())
} else {
bail!(
print_warning(&format!(
"No [package.metadata.bundle.{}.{}] section in Cargo.toml",
map_name,
bundle_name
);
map_name, bundle_name
))?;
Ok(BundleSettings::default())
}
}

Expand Down

0 comments on commit c500f23

Please sign in to comment.