Skip to content

Commit fa21a69

Browse files
committed
Write a list of used icons to the /interim directory
So that the icons can be more timely pre-fetched/included by consumer applications like iD
1 parent ba62be1 commit fa21a69

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

lib/build.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ function processData(options, type) {
146146
translationsForYaml[sourceLocale] = { presets: translations };
147147
fs.writeFileSync(interimDir + '/source_strings.yaml', translationsToYAML(translationsForYaml));
148148

149+
let icons = generateIconsList(presets, fields);
150+
fs.writeFileSync(interimDir + '/icons.json', JSON.stringify(icons, null, 4));
151+
149152
if (type !== 'build-dist') return;
150153

151154
const doFetchTranslations = options.translOrgId && options.translProjectId;
@@ -680,6 +683,15 @@ function generateTaginfo(presets, fields, deprecated, discarded, tstrings, proje
680683
return taginfo;
681684
}
682685

686+
function generateIconsList(presets, fields) {
687+
const icons = {};
688+
[
689+
...Object.values(presets).map(p => p.icon).filter(Boolean),
690+
...Object.values(fields).flatMap(f => Object.values(f.icons || {}))
691+
].forEach(icon => icons[icon] = true)
692+
return Object.keys(icons).sort();
693+
}
694+
683695

684696
function validateCategoryPresets(categories, presets) {
685697
Object.keys(categories).forEach(id => {

0 commit comments

Comments
 (0)