summaryrefslogtreecommitdiff
path: root/cli/npm/resolution/snapshot.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/npm/resolution/snapshot.rs')
-rw-r--r--cli/npm/resolution/snapshot.rs27
1 files changed, 26 insertions, 1 deletions
diff --git a/cli/npm/resolution/snapshot.rs b/cli/npm/resolution/snapshot.rs
index bdc204ce8..3fc82cbb8 100644
--- a/cli/npm/resolution/snapshot.rs
+++ b/cli/npm/resolution/snapshot.rs
@@ -1,5 +1,6 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+use std::collections::BTreeMap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::sync::Arc;
@@ -42,7 +43,7 @@ impl NpmPackagesPartitioned {
}
}
-#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
+#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
pub struct NpmResolutionSnapshot {
/// The unique package requirements map to a single npm package name and version.
#[serde(with = "map_to_vec")]
@@ -55,6 +56,30 @@ pub struct NpmResolutionSnapshot {
pub(super) packages: HashMap<NpmPackageId, NpmResolutionPackage>,
}
+impl std::fmt::Debug for NpmResolutionSnapshot {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ // do a custom debug implementation that creates deterministic output for the tests
+ f.debug_struct("NpmResolutionSnapshot")
+ .field(
+ "package_reqs",
+ &self.package_reqs.iter().collect::<BTreeMap<_, _>>(),
+ )
+ .field(
+ "root_packages",
+ &self.root_packages.iter().collect::<BTreeMap<_, _>>(),
+ )
+ .field(
+ "packages_by_name",
+ &self.packages_by_name.iter().collect::<BTreeMap<_, _>>(),
+ )
+ .field(
+ "packages",
+ &self.packages.iter().collect::<BTreeMap<_, _>>(),
+ )
+ .finish()
+ }
+}
+
// This is done so the maps with non-string keys get serialized and deserialized as vectors.
// Adapted from: https://github.com/serde-rs/serde/issues/936#issuecomment-302281792
mod map_to_vec {