fix(cli/info): fix crash when checking node version (#9412)

closes #9396
This commit is contained in:
Amr Bashir 2024-04-15 11:39:19 +02:00 committed by GitHub
parent cd23bb2ca2
commit 9331435a50
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 11 deletions

View File

@ -0,0 +1,6 @@
---
"tauri-cli": "patch:bug"
"@tauri-apps/cli": "patch:bug"
---
Fix `tauri info` crashing when Node.js is not installed.

View File

@ -42,17 +42,17 @@ pub fn items(metadata: &VersionMetadata) -> Vec<SectionItem> {
.unwrap_or_default()
.trim();
ActionResult::Description(format!("node: {}{}", v, {
let version = semver::Version::parse(v).unwrap();
let target_version = semver::Version::parse(node_target_ver.as_str()).unwrap();
if version < target_version {
format!(
" ({}, latest: {})",
"outdated".red(),
target_version.to_string().green()
)
} else {
"".into()
}
let version = semver::Version::parse(v);
let target_version = semver::Version::parse(node_target_ver.as_str());
match (version, target_version) {
(Ok(version), Ok(target_version)) if version < target_version => {
format!(
" ({}, latest: {})",
"outdated".red(),
target_version.to_string().green()
)
}
_ => "".into(),
}))
} else {
ActionResult::None