fix(cli.rs): fix tauri info panic when a package isn't installed, closes #3985 (#3996)

This commit is contained in:
Amr Bashir
2022-04-29 18:29:31 +02:00
committed by GitHub
parent 094534d138
commit 4f0f3187c9
3 changed files with 8 additions and 10 deletions

View File

@@ -0,0 +1,6 @@
---
"cli.rs": patch
"cli.js": patch
---
Fix `tauri info` panic when a pacakage isn't installed.

View File

@@ -1,7 +1,7 @@
{
"cli.js": {
"version": "1.0.0-rc.9",
"node": ">= 10"
"node": ">= 10.0.0"
},
"tauri": "1.0.0-rc.8",
"tauri-build": "1.0.0-rc.7"

View File

@@ -494,7 +494,6 @@ struct VersionBlock {
version: String,
target_version: String,
indentation: usize,
skip_update_check: bool,
}
impl VersionBlock {
@@ -504,15 +503,9 @@ impl VersionBlock {
version: version.into(),
target_version: "".into(),
indentation: 2,
skip_update_check: false,
}
}
fn skip_update_check(mut self) -> Self {
self.skip_update_check = true;
self
}
fn target_version(mut self, version: impl Into<String>) -> Self {
self.target_version = version.into();
self
@@ -531,7 +524,7 @@ impl VersionBlock {
self.version.clone()
}
);
if !self.target_version.is_empty() && !self.skip_update_check {
if !(self.version.is_empty() || self.target_version.is_empty()) {
let version = semver::Version::parse(self.version.as_str()).unwrap();
let target_version = semver::Version::parse(self.target_version.as_str()).unwrap();
if version < target_version {
@@ -630,7 +623,6 @@ pub fn command(_options: Options) -> Result<()> {
.collect::<String>(),
)
.target_version(metadata.js_cli.node.replace(">= ", ""))
.skip_update_check()
.display();
VersionBlock::new(