Przeglądaj źródła

fix(cli): not working with `license.workspace = true` (#9998)

anatawa12 1 rok temu
rodzic
commit
a423c52c1c
1 zmienionych plików z 12 dodań i 2 usunięć
  1. 12 2
      tooling/cli/src/interface/rust.rs

+ 12 - 2
tooling/cli/src/interface/rust.rs

@@ -607,6 +607,7 @@ struct WorkspacePackageSettings {
   description: Option<String>,
   homepage: Option<String>,
   version: Option<String>,
+  license: Option<String>,
 }
 
 #[derive(Clone, Debug, Deserialize)]
@@ -630,7 +631,7 @@ pub struct CargoPackageSettings {
   /// the package's authors.
   pub authors: Option<MaybeWorkspace<Vec<String>>>,
   /// the package's license.
-  pub license: Option<String>,
+  pub license: Option<MaybeWorkspace<String>>,
   /// the default binary to run.
   pub default_run: Option<String>,
 }
@@ -910,7 +911,16 @@ impl RustAppSettings {
           })
           .unwrap()
       }),
-      license: cargo_package_settings.license.clone(),
+      license: cargo_package_settings.license.clone().map(|license| {
+        license
+          .resolve("license", || {
+            ws_package_settings
+              .as_ref()
+              .and_then(|v| v.license.clone())
+              .ok_or_else(|| anyhow::anyhow!("Couldn't inherit value for `license` from workspace"))
+          })
+          .unwrap()
+      }),
       default_run: cargo_package_settings.default_run.clone(),
     };