From 6873cb2c441d16c214c2ee51364dd5edcf829d05 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Tue, 12 Nov 2024 11:50:45 +0000 Subject: [PATCH] Update merge script to remove duplicates --- scripts/merge-yaml.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/merge-yaml.js b/scripts/merge-yaml.js index b4df399..42a3cc6 100644 --- a/scripts/merge-yaml.js +++ b/scripts/merge-yaml.js @@ -31,12 +31,14 @@ function sortAndMergeYAMLFiles() { return codeA - codeB }) - const mergedYaml = yaml.stringify(mergedData); + - // Construct the output string + // Construct the output string, removing duplicates let outputString = "pis:\n"; + const seenCodes = new Set(); mergedData.forEach(item => { - if (item.stops.length > 0) { + if (!seenCodes.has(item.code) && item.stops.length > 0) { + seenCodes.add(item.code); outputString += ` - code: "${item.code}"\n`; outputString += ` stops: [${item.stops.map(stop => `${stop}`).join(',')}]\n`; outputString += ` toc: "${item.toc || "gw"}"\n`;