Bläddra i källkod

fix(cli.rs): fix out dir detection when target arg is set, closes #2040 (#2098)

Lucas Fernandes Nogueira 4 år sedan
förälder
incheckning
8e23870189

+ 5 - 0
.changes/fix-cli-target-set.md

@@ -0,0 +1,5 @@
+---
+"cli.rs": patch
+---
+
+Fixes `build` command when the `target` arg is set.

+ 1 - 1
tooling/cli.rs/src/build.rs

@@ -128,7 +128,7 @@ impl Build {
     let app_settings = crate::interface::rust::AppSettings::new(config_)?;
 
     let out_dir = app_settings
-      .get_out_dir(self.debug)
+      .get_out_dir(self.target.clone(), self.debug)
       .with_context(|| "failed to get project out directory")?;
     if let Some(product_name) = config_.package.product_name.clone() {
       let bin_name = app_settings.cargo_package_settings().name.clone();

+ 1 - 1
tooling/cli.rs/src/dev.rs

@@ -102,7 +102,7 @@ impl Dev {
       let config_ = config_guard.as_ref().unwrap();
       let app_settings = crate::interface::rust::AppSettings::new(config_)?;
       let out_dir = app_settings
-        .get_out_dir(true)
+        .get_out_dir(self.target.clone(), true)
         .with_context(|| "failed to get project out directory")?;
       let settings = crate::interface::get_bundler_settings(
         app_settings,

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

@@ -186,10 +186,10 @@ impl AppSettings {
     )
   }
 
-  pub fn get_out_dir(&self, debug: bool) -> crate::Result<PathBuf> {
+  pub fn get_out_dir(&self, target: Option<String>, debug: bool) -> crate::Result<PathBuf> {
     let tauri_dir = tauri_dir();
     let workspace_dir = get_workspace_dir(&tauri_dir);
-    get_target_dir(&workspace_dir, None, !debug)
+    get_target_dir(&workspace_dir, target, !debug)
   }
 
   pub fn get_package_settings(&self) -> PackageSettings {