feat(cli): improve error message with invalid target for build (#8321)

This commit is contained in:
Ananth
2023-12-12 03:36:43 +05:30
committed by GitHub
parent 940ec1dd01
commit b6ca8885ff

View File

@@ -228,8 +228,16 @@ impl Interface for Rust {
self.app_settings.target_triple.clone(),
);
let mut s = self.app_settings.target_triple.split('-');
let (arch, _, host) = (s.next().unwrap(), s.next().unwrap(), s.next().unwrap());
let target_triple = &self.app_settings.target_triple;
let target_components: Vec<&str> = target_triple.split('-').collect();
let (arch, host) = match target_components.as_slice() {
[arch, _, host] => (*arch, *host),
_ => {
log::warn!("Invalid target triple: {}", target_triple);
return env;
}
};
env.insert(
"TAURI_ENV_ARCH",
match arch {