Skip to content

Commit

Permalink
Adjust check scripts to be case insensitive (Closes #494)
Browse files Browse the repository at this point in the history
  • Loading branch information
PKief committed Jul 17, 2019
1 parent 87b183f commit 9fa2dd2
Showing 1 changed file with 40 additions and 36 deletions.
76 changes: 40 additions & 36 deletions src/scripts/icons/checks/checkIconConflicts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
});
});
});
};

Expand All @@ -50,37 +51,40 @@ 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);
}
}
});
});
});
};

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);
}
}
}
});
});
});
};

Expand All @@ -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('--------------------------------------'));

Expand All @@ -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!`));
}
};
Expand Down

0 comments on commit 9fa2dd2

Please sign in to comment.