From aa39f31fa9a789fd5c9082d40854d4e9dd5e957f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Tue, 8 Jan 2019 00:30:06 -0500 Subject: [PATCH] Cleanup changelog entries dedupe function --- scripts/changelog.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/scripts/changelog.js b/scripts/changelog.js index 39ad7584..753b9365 100644 --- a/scripts/changelog.js +++ b/scripts/changelog.js @@ -670,23 +670,17 @@ function parse(entries) { } function dedupeEntries(changelog, items) { - const isNewEntry = (entry) => !changelog.includes(printEntryLink(entry)); + const dedupe = (entries) => + entries.filter((entry) => !changelog.includes(printEntryLink(entry))); - items.deprecations = items.deprecations.filter(isNewEntry); - items.documentation = items.documentation.filter(isNewEntry); - items.websiteDocumentation = items.websiteDocumentation.filter(isNewEntry); - items.internals = items.documentation.filter(isNewEntry); - items.security = items.documentation.filter(isNewEntry); - items.uncategorized.feature = items.uncategorized.feature.filter(isNewEntry); - items.uncategorized.bug = items.uncategorized.bug.filter(isNewEntry); - items.uncategorized.other = items.uncategorized.other.filter(isNewEntry); - - Object.entries(items.dependencies).forEach(([name, entries]) => { - items.dependencies[name] = entries.filter(isNewEntry); + ["deprecations", "documentation", "websiteDocumentation", "internals", "security"].forEach((type) => { + items[type] = dedupe(items[type]); }); - Object.entries(items.devDependencies).forEach(([name, entries]) => { - items.devDependencies[name] = entries.filter(isNewEntry); + ["dependencies", "devDependencies", "uncategorized"].forEach((type) => { + Object.entries(items[type]).forEach(([name, entries]) => { + items[type][name] = dedupe(entries); + }); }); }