From 9fa2dd27a7ff57235f94c38233f2ffb2a6b9eaaa Mon Sep 17 00:00:00 2001 From: PKief Date: Wed, 17 Jul 2019 23:05:03 +0200 Subject: [PATCH] Adjust check scripts to be case insensitive (Closes #494) --- .../icons/checks/checkIconConflicts.ts | 76 ++++++++++--------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/src/scripts/icons/checks/checkIconConflicts.ts b/src/scripts/icons/checks/checkIconConflicts.ts index fb21fcd48a..9616f28d29 100644 --- a/src/scripts/icons/checks/checkIconConflicts.ts +++ b/src/scripts/icons/checks/checkIconConflicts.ts @@ -29,19 +29,20 @@ const checkFileIcons = () => { const checkForConflictsInFileIcons = (fileIconDefinitionType: string) => { const icons = {}; fileIcons.icons.forEach(icon => { - if (!icon[fileIconDefinitionType]) return {}; - icon[fileIconDefinitionType].forEach(ext => { - if (!icons[ext] || icon.enabledFor && icon.enabledFor.length > 0) { - icons[ext] = icon.name; - } - else { - if (!allConflicts.fileIcons[fileIconDefinitionType][ext]) { - allConflicts.fileIcons[fileIconDefinitionType][ext] = [icons[ext], icon.name]; + if (!icon[fileIconDefinitionType]) return; + icon[fileIconDefinitionType] + .map(d => d.toLowerCase()) + .forEach(definition => { + if (!icons[definition] || icon.enabledFor && icon.enabledFor.length > 0) { + icons[definition] = icon.name; } else { - allConflicts.fileIcons[fileIconDefinitionType][ext].push(icon.name); + if (!allConflicts.fileIcons[fileIconDefinitionType][definition]) { + allConflicts.fileIcons[fileIconDefinitionType][definition] = [icons[definition], icon.name]; + } else { + allConflicts.fileIcons[fileIconDefinitionType][definition].push(icon.name); + } } - } - }); + }); }); }; @@ -50,18 +51,20 @@ const checkFolderIcons = () => { if (!theme.icons) return; const icons = {}; theme.icons.forEach(icon => { - icon.folderNames.forEach(folderName => { - if (!icons[folderName] || icon.enabledFor && icon.enabledFor.length > 0) { - icons[folderName] = icon.name; - } - else { - if (!allConflicts.folderIcons[folderName]) { - allConflicts.folderIcons[folderName] = [icons[folderName], icon.name]; - } else { - allConflicts.folderIcons[folderName].push(icon.name); + icon.folderNames + .map(f => f.toLowerCase()) + .forEach(folderName => { + if (!icons[folderName] || icon.enabledFor && icon.enabledFor.length > 0) { + icons[folderName] = icon.name; } - } - }); + else { + if (!allConflicts.folderIcons[folderName]) { + allConflicts.folderIcons[folderName] = [icons[folderName], icon.name]; + } else { + allConflicts.folderIcons[folderName].push(icon.name); + } + } + }); }); }); }; @@ -69,18 +72,19 @@ const checkFolderIcons = () => { const checkLanguageIcons = () => { const icons = {}; languageIcons.forEach(langIcon => { - langIcon.ids.forEach(id => { - if (!icons[id]) { - icons[id] = langIcon.icon.name; - } - else { - if (!allConflicts.languageIcons[id]) { - allConflicts.languageIcons[id] = [icons[id], langIcon.icon.name]; + langIcon.ids + .map(id => id.toLowerCase()) + .forEach(id => { + if (!icons[id]) { + icons[id] = langIcon.icon.name; } else { - allConflicts.languageIcons[id].push(langIcon.icon.name); + if (!allConflicts.languageIcons[id]) { + allConflicts.languageIcons[id] = [icons[id], langIcon.icon.name]; + } else { + allConflicts.languageIcons[id].push(langIcon.icon.name); + } } - } - }); + }); }); }; @@ -89,8 +93,8 @@ const handleErrors = () => { ...Object.keys(allConflicts.fileIcons.fileExtensions), ...Object.keys(allConflicts.fileIcons.fileNames), ...Object.keys(allConflicts.folderIcons), - ...Object.keys(allConflicts.languageIcons)].length > 0 - ) { + ...Object.keys(allConflicts.languageIcons) + ].length > 0) { console.log('> Material Icon Theme:', painter.red('Icon conflicts:')); console.log(painter.red('--------------------------------------')); @@ -100,8 +104,8 @@ const handleErrors = () => { printErrorMessage(allConflicts.languageIcons, 'languageId'); console.log('\n' + painter.red('Please check the wrong icon configurations!\n')); - } - else { + process.exit(1); + } else { console.log('> Material Icon Theme:', painter.green(`Passed icon conflict checks!`)); } };