Skip to content

Commit

Permalink
fix(cli/info): fix crash when checking node version (#9411)
Browse files Browse the repository at this point in the history
closes #9396
  • Loading branch information
amrbashir authored Apr 15, 2024
1 parent fe6f81f commit aeddc40
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .changes/tauri-info-no-node.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"tauri-cli": "patch:bug"
"@tauri-apps/cli": "patch:bug"
---

Fix `tauri info` crashing when Node.js is not installed.

21 changes: 11 additions & 10 deletions tooling/cli/src/info/env_nodejs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,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 {
Expand Down

0 comments on commit aeddc40

Please sign in to comment.