Skip to content

Commit 12f6521

Browse files
authored
fix(cli): read lockfile from workspace on the info command, closes #4232 (#4423)
1 parent 35dd51d commit 12f6521

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

.changes/info-command-workspace.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+
"cli.js": patch
4+
---
5+
6+
The `info` command now can check the Cargo lockfile on workspaces.

tooling/cli/src/info.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
// SPDX-License-Identifier: Apache-2.0
33
// SPDX-License-Identifier: MIT
44

5-
use crate::helpers::{
6-
config::get as get_config, framework::infer_from_package_json as infer_framework,
5+
use crate::{
6+
helpers::{config::get as get_config, framework::infer_from_package_json as infer_framework},
7+
interface::rust::get_workspace_dir,
8+
Result,
79
};
8-
use crate::Result;
910
use clap::Parser;
1011
use colored::Colorize;
1112
use serde::Deserialize;
@@ -476,12 +477,12 @@ fn crate_version(
476477
};
477478

478479
let lock_version = match (lock, crate_lock_packages.is_empty()) {
479-
(Some(_lock), true) => crate_lock_packages
480+
(Some(_lock), false) => crate_lock_packages
480481
.iter()
481482
.map(|p| p.version.clone())
482483
.collect::<Vec<String>>()
483484
.join(", "),
484-
(Some(_lock), false) => "unknown lockfile".to_string(),
485+
(Some(_lock), true) => "unknown lockfile".to_string(),
485486
_ => "no lockfile".to_string(),
486487
};
487488

@@ -789,12 +790,13 @@ pub fn command(_options: Options) -> Result<()> {
789790
} else {
790791
None
791792
};
792-
let lock: Option<CargoLock> =
793-
if let Ok(lock_contents) = read_to_string(tauri_dir.join("Cargo.lock")) {
794-
toml::from_str(&lock_contents).ok()
795-
} else {
796-
None
797-
};
793+
let lock: Option<CargoLock> = if let Ok(lock_contents) =
794+
read_to_string(get_workspace_dir(&tauri_dir).join("Cargo.lock"))
795+
{
796+
toml::from_str(&lock_contents).ok()
797+
} else {
798+
None
799+
};
798800

799801
for (dep, label) in [
800802
("tauri", format!("{} {}", "tauri", "[RUST]".dimmed())),

0 commit comments

Comments
 (0)