diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-09-26 10:24:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-26 14:24:49 +0000 |
commit | b80cf1f5e7a10567f2a39b2f3872735f951dd3a4 (patch) | |
tree | 64cc540bfbe254b3389da77d3fe61ebee00d001b | |
parent | 92529697807a652b627a7dbd4f5d0c3ad7bacf59 (diff) |
refactor: use ModuleGraph::fill_from_lockfile (#25887)
-rw-r--r-- | cli/graph_util.rs | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/cli/graph_util.rs b/cli/graph_util.rs index d8f7ae749..8a6839919 100644 --- a/cli/graph_util.rs +++ b/cli/graph_util.rs @@ -21,6 +21,7 @@ use crate::util::file_watcher::WatcherCommunicator; use crate::util::fs::canonicalize_path; use deno_config::workspace::JsrPackageConfig; use deno_graph::source::LoaderChecksum; +use deno_graph::FillFromLockfileOptions; use deno_graph::JsrLoadError; use deno_graph::ModuleLoadError; use deno_graph::WorkspaceFastCheckOption; @@ -44,7 +45,6 @@ use deno_runtime::deno_permissions::PermissionsContainer; use deno_runtime::fs_util::specifier_to_file_path; use deno_semver::jsr::JsrDepPackageReq; use deno_semver::package::PackageNv; -use deno_semver::Version; use import_map::ImportMapError; use std::collections::HashSet; use std::error::Error; @@ -573,33 +573,19 @@ impl ModuleGraphBuilder { // populate the information from the lockfile if let Some(lockfile) = &self.lockfile { let lockfile = lockfile.lock(); - for (from, to) in &lockfile.content.redirects { - if let Ok(from) = ModuleSpecifier::parse(from) { - if let Ok(to) = ModuleSpecifier::parse(to) { - if !matches!(from.scheme(), "file" | "npm" | "jsr") { - graph.redirects.insert(from, to); - } - } - } - } - for (req_dep, value) in &lockfile.content.packages.specifiers { - match req_dep.kind { - deno_semver::package::PackageKind::Jsr => { - if let Ok(version) = Version::parse_standard(value) { - graph.packages.add_nv( - req_dep.req.clone(), - PackageNv { - name: req_dep.req.name.clone(), - version, - }, - ); - } - } - deno_semver::package::PackageKind::Npm => { - // ignore - } - } - } + graph.fill_from_lockfile(FillFromLockfileOptions { + redirects: lockfile + .content + .redirects + .iter() + .map(|(from, to)| (from.as_str(), to.as_str())), + package_specifiers: lockfile + .content + .packages + .specifiers + .iter() + .map(|(dep, id)| (dep, id.as_str())), + }); } } |