Browse Source

feat(cli.rs): improve error message on app rename, closes #2101 (#2114)

Lucas Fernandes Nogueira 4 years ago
parent
commit
1a41e9f040
2 changed files with 19 additions and 5 deletions
  1. 5 0
      .changes/cli-error-message.md
  2. 14 5
      tooling/cli.rs/src/build.rs

+ 5 - 0
.changes/cli-error-message.md

@@ -0,0 +1,5 @@
+---
+"cli.rs": patch
+---
+
+Improve error message when the product name is invalid.

+ 14 - 5
tooling/cli.rs/src/build.rs

@@ -133,12 +133,21 @@ impl Build {
     if let Some(product_name) = config_.package.product_name.clone() {
     if let Some(product_name) = config_.package.product_name.clone() {
       let bin_name = app_settings.cargo_package_settings().name.clone();
       let bin_name = app_settings.cargo_package_settings().name.clone();
       #[cfg(windows)]
       #[cfg(windows)]
-      rename(
-        out_dir.join(format!("{}.exe", bin_name)),
-        out_dir.join(format!("{}.exe", product_name)),
-      )?;
+      let (bin_path, product_path) = {
+        (
+          out_dir.join(format!("{}.exe", bin_name)),
+          out_dir.join(format!("{}.exe", product_name)),
+        )
+      };
       #[cfg(not(windows))]
       #[cfg(not(windows))]
-      rename(out_dir.join(bin_name), out_dir.join(product_name))?;
+      let (bin_path, product_path) = { (out_dir.join(bin_name), out_dir.join(product_name)) };
+      rename(&bin_path, &product_path).with_context(|| {
+        format!(
+          "failed to rename `{}` to `{}`",
+          bin_path.display(),
+          product_path.display(),
+        )
+      })?;
     }
     }
 
 
     if config_.tauri.bundle.active {
     if config_.tauri.bundle.active {