From 1c338f416c0b032513421f3a4debccdf195555ae Mon Sep 17 00:00:00 2001 From: firefoxic Date: Wed, 25 Dec 2024 08:46:56 +0300 Subject: [PATCH] Fix generation of `maxDensity` field value in metadata files --- CHANGELOG.md | 4 ++++ lib/processRaster.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51ebab2..3b111bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and  ## [Unreleased] +### Fixed + +- The `maxDensity` field in metadata files when `-max-density 1` is specified now gets the correct value instead of the erroneous `null`. + ## [3.0.0] — 2024–12–15 ### Changed diff --git a/lib/processRaster.js b/lib/processRaster.js index 77c542c..22c0f13 100644 --- a/lib/processRaster.js +++ b/lib/processRaster.js @@ -108,7 +108,7 @@ export async function processRaster (options) { let isMetaFileExists = await fileExists(metaJsonPath) let metaData = isMetaFileExists ? await readJsonFile(metaJsonPath) : {} - metaData.maxDensity = Math.max(metaData.maxDensity, originDensity) + metaData.maxDensity = metaData.maxDensity ? Math.max(metaData.maxDensity, originDensity) : originDensity metaData.formats = Array.from(new Set([...metaData.formats || [], ...formats])) metaData.sizes = Array.from(new Set([...metaData.sizes || [], ...sizes].sort((a, b) => { if (!a.breakpoint) return 1