Skip to content

Commit c260842

Browse files
fix(cli): don't panic when a crate version couldn't be parsed (#5873)
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.studio>
1 parent 1956a3a commit c260842

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.changes/cli-info.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"cli.rs": "patch"
3+
---
4+
5+
Fix `tauri info` panicking when parsing crates version on a newly created project without a `Cargo.lock` file.
6+

tooling/cli/src/info.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,10 @@ fn crate_version(
499499

500500
let crate_version = found_crate_versions
501501
.into_iter()
502-
.map(|v| semver::Version::parse(&v).unwrap())
502+
.map(|v| semver::Version::parse(&v).ok())
503503
.max();
504504
let suffix = match (crate_version, crate_latest_version(name)) {
505-
(Some(version), Some(target_version)) => {
505+
(Some(Some(version)), Some(target_version)) => {
506506
let target_version = semver::Version::parse(&target_version).unwrap();
507507
if version < target_version {
508508
Some(format!(" (outdated, latest: {target_version})"))

0 commit comments

Comments
 (0)