summaryrefslogtreecommitdiff
path: root/cli/npm/resolution/mod.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-02-21 15:19:09 -0500
committerGitHub <noreply@github.com>2023-02-21 15:19:09 -0500
commit5becfd6381889287ff16a064128021f87c8dfcb6 (patch)
treee6931d7794eb195075dd214002e4c1bf69647b2d /cli/npm/resolution/mod.rs
parent69c0b05f7ab72f957ce7685998d3f424fb7e812c (diff)
fix(npm): filter out duplicate packages names in resolution (#17857)
Diffstat (limited to 'cli/npm/resolution/mod.rs')
-rw-r--r--cli/npm/resolution/mod.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/cli/npm/resolution/mod.rs b/cli/npm/resolution/mod.rs
index 90bf16c43..c95124b61 100644
--- a/cli/npm/resolution/mod.rs
+++ b/cli/npm/resolution/mod.rs
@@ -1,6 +1,7 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use std::cmp::Ordering;
+use std::collections::BTreeMap;
use std::collections::HashMap;
use std::collections::HashSet;
@@ -191,7 +192,7 @@ impl PartialOrd for NpmPackageId {
}
}
-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
+#[derive(Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct NpmResolutionPackage {
pub pkg_id: NpmPackageId,
/// The peer dependency resolution can differ for the same
@@ -205,6 +206,21 @@ pub struct NpmResolutionPackage {
pub dependencies: HashMap<String, NpmPackageId>,
}
+impl std::fmt::Debug for NpmResolutionPackage {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ // custom debug implementation for deterministic output in the tests
+ f.debug_struct("NpmResolutionPackage")
+ .field("pkg_id", &self.pkg_id)
+ .field("copy_index", &self.copy_index)
+ .field("dist", &self.dist)
+ .field(
+ "dependencies",
+ &self.dependencies.iter().collect::<BTreeMap<_, _>>(),
+ )
+ .finish()
+ }
+}
+
impl NpmResolutionPackage {
pub fn get_package_cache_folder_id(&self) -> NpmPackageCacheFolderId {
NpmPackageCacheFolderId {