From 07be4c379c06defe4df8ad42135124fcf4c73567 Mon Sep 17 00:00:00 2001 From: Ian Bull Date: Sat, 7 Dec 2024 16:49:22 -0800 Subject: [PATCH] Lowercase the specifiers --- cli/tools/registry/pm/outdated.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cli/tools/registry/pm/outdated.rs b/cli/tools/registry/pm/outdated.rs index ea4f8eedb239ff..dfc491fc8037ef 100644 --- a/cli/tools/registry/pm/outdated.rs +++ b/cli/tools/registry/pm/outdated.rs @@ -10,6 +10,7 @@ use deno_semver::package::PackageReq; use deno_semver::VersionReq; use deno_terminal::colors; use serde::Serialize; +use serde::Serializer; use crate::args::CacheSetting; use crate::args::CliOptions; @@ -29,7 +30,7 @@ use super::deps::PackageLatestVersion; #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Serialize)] struct OutdatedPackage { - #[serde(rename = "specifier")] + #[serde(rename = "specifier", serialize_with = "lowercase_serializer")] kind: DepKind, #[serde(rename = "latest")] latest: String, @@ -40,6 +41,16 @@ struct OutdatedPackage { name: String, } +fn lowercase_serializer(kind: &DepKind, s: S) -> Result +where + S: Serializer, +{ + match kind { + DepKind::Npm => s.serialize_str("npm"), + DepKind::Jsr => s.serialize_str("jsr"), + } +} + #[allow(clippy::print_stdout)] fn print_outdated_table(packages: &[OutdatedPackage]) { const HEADINGS: &[&str] = &["Package", "Current", "Update", "Latest"];