Skip to content

Commit 1a41e9f

Browse files
authored
feat(cli.rs): improve error message on app rename, closes #2101 (#2114)
1 parent 8b7ac1a commit 1a41e9f

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

.changes/cli-error-message.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"cli.rs": patch
3+
---
4+
5+
Improve error message when the product name is invalid.

tooling/cli.rs/src/build.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,21 @@ impl Build {
133133
if let Some(product_name) = config_.package.product_name.clone() {
134134
let bin_name = app_settings.cargo_package_settings().name.clone();
135135
#[cfg(windows)]
136-
rename(
137-
out_dir.join(format!("{}.exe", bin_name)),
138-
out_dir.join(format!("{}.exe", product_name)),
139-
)?;
136+
let (bin_path, product_path) = {
137+
(
138+
out_dir.join(format!("{}.exe", bin_name)),
139+
out_dir.join(format!("{}.exe", product_name)),
140+
)
141+
};
140142
#[cfg(not(windows))]
141-
rename(out_dir.join(bin_name), out_dir.join(product_name))?;
143+
let (bin_path, product_path) = { (out_dir.join(bin_name), out_dir.join(product_name)) };
144+
rename(&bin_path, &product_path).with_context(|| {
145+
format!(
146+
"failed to rename `{}` to `{}`",
147+
bin_path.display(),
148+
product_path.display(),
149+
)
150+
})?;
142151
}
143152

144153
if config_.tauri.bundle.active {

0 commit comments

Comments
 (0)