Skip to content

Commit db6804d

Browse files
authored
fix(cli): do not add --release when --profile=<name> is passed (#16126)
1 parent 10ad4e5 commit db6804d

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

‎.changes/cli-profile-equals-arg.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-cli": patch:bug
3+
"@tauri-apps/cli": patch:bug
4+
---
5+
6+
Fix `--release` being added to the cargo command when a custom profile is passed as `--profile=<name>`, which made cargo reject the build.

‎crates/tauri-cli/src/interface/rust/desktop.rs‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ fn cargo_command(
267267
build_cmd.arg(features.join(","));
268268
}
269269

270-
if !options.debug && !options.args.contains(&"--profile".to_string()) {
270+
if !options.debug && super::get_cargo_option(&options.args, "--profile").is_none() {
271271
build_cmd.arg("--release");
272272
}
273273

@@ -430,3 +430,27 @@ mod terminal {
430430
}
431431
}
432432
}
433+
434+
#[cfg(test)]
435+
mod tests {
436+
use super::{Options, cargo_command};
437+
438+
fn release_args(args: &[&str]) -> Vec<String> {
439+
let options = Options {
440+
args: args.iter().map(ToString::to_string).collect(),
441+
..Default::default()
442+
};
443+
cargo_command(false, options, &mut None, Vec::new())
444+
.unwrap()
445+
.get_args()
446+
.map(|a| a.to_string_lossy().into_owned())
447+
.collect()
448+
}
449+
450+
#[test]
451+
fn release_flag_respects_profile() {
452+
assert!(release_args(&[]).contains(&"--release".to_string()));
453+
assert!(!release_args(&["--profile", "custom"]).contains(&"--release".to_string()));
454+
assert!(!release_args(&["--profile=custom"]).contains(&"--release".to_string()));
455+
}
456+
}

0 commit comments

Comments
 (0)