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() .unwrap_or_default()
.trim(); .trim();
ActionResult::Description(format!("node: {}{}", v, { ActionResult::Description(format!("node: {}{}", v, {
let version = semver::Version::parse(v).unwrap(); let version = semver::Version::parse(v);
let target_version = semver::Version::parse(node_target_ver.as_str()).unwrap(); let target_version = semver::Version::parse(node_target_ver.as_str());
if version < target_version { match (version, target_version) {
format!( (Ok(version), Ok(target_version)) if version < target_version => {
" ({}, latest: {})", format!(
"outdated".red(), " ({}, latest: {})",
target_version.to_string().green() "outdated".red(),
) target_version.to_string().green()
} else { )
"".into() }
} _ => "".into(),
})) }))
} else { } else {
ActionResult::None ActionResult::None