Skip to content

Commit

Permalink
chore: wrap some CrateMetadata code into block
Browse files Browse the repository at this point in the history
  • Loading branch information
dj8yf0μl committed Oct 24, 2024
1 parent 46cdd06 commit 6c9b22e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions cargo-near-build/src/types/cargo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ impl CrateMetadata {
no_locked: bool,
cargo_target_dir: Option<&buildtime_env::CargoTargetDir>,
) -> eyre::Result<Self> {
let (mut metadata, root_package) =
get_cargo_metadata(&manifest_path, no_locked, cargo_target_dir)?;

metadata.target_directory = crate::fs::force_canonicalize_dir(&metadata.target_directory)?;
metadata.workspace_root = metadata.workspace_root.canonicalize_utf8()?;
let (metadata, root_package) = {
let (mut metadata, root_package) =
get_cargo_metadata(&manifest_path, no_locked, cargo_target_dir)?;
metadata.target_directory =
crate::fs::force_canonicalize_dir(&metadata.target_directory)?;
metadata.workspace_root = metadata.workspace_root.canonicalize_utf8()?;
(metadata, root_package)
};

let mut target_directory =
crate::fs::force_canonicalize_dir(&metadata.target_directory.join("near"))?;
Expand Down Expand Up @@ -89,11 +92,11 @@ impl CrateMetadata {
.deps
.iter()
.find(|dep| dep.name == dependency_name)
.and_then(|near_sdk| {
.and_then(|found_dependency| {
self.raw_metadata
.packages
.iter()
.find(|pkg| pkg.id == near_sdk.pkg)
.find(|pkg| pkg.id == found_dependency.pkg)
})
.wrap_err(format!("`{}` dependency not found", dependency_name))
}
Expand Down

0 comments on commit 6c9b22e

Please sign in to comment.