Skip to content

Commit

Permalink
[core] Sanitize input in icon synonyms update script (mui#33989)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak authored and Daniel Rabe committed Nov 29, 2022
1 parent 23db9ad commit b97ccb6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions docs/scripts/updateIconSynonyms.js
Expand Up @@ -21,8 +21,23 @@ async function run() {
const data = JSON.parse(text.replace(")]}'", ''));

const materialIcons = data.icons.reduce((acc, icon) => {
// remove the icon name strings from the tags
icon.tags = not(icon.tags, icon.name.replace('_'));
icon.tags = not(icon.tags, icon.name.replace('_')) // remove the icon name strings from the tags
.filter((t) => {
// remove invalid tags
if (
t.includes('Remove') ||
t.includes('Duplicate') ||
t.includes('Same as') ||
t.includes('remove others')
) {
console.log(`Skipping invalid tag (${t}) in ${icon.name}`);
return false;
}

return true;
})
.map((t) => t.replace(/'/g, ''));

// Fix names that can't be exported as ES modules.
icon.name = myDestRewriter({ base: icon.name });

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -28,7 +28,7 @@
"docs:typescript": "yarn docs:typescript:formatted --watch",
"docs:typescript:check": "yarn workspace docs typescript",
"docs:typescript:formatted": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js\" ./docs/scripts/formattedTSDemos",
"docs:mdicons:synonyms": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js\" ./docs/scripts/updateIconSynonyms",
"docs:mdicons:synonyms": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js\" ./docs/scripts/updateIconSynonyms && yarn prettier",
"extract-error-codes": "cross-env MUI_EXTRACT_ERROR_CODES=true lerna run --parallel build:modern",
"template:screenshot": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js\" ./docs/scripts/generateTemplateScreenshots",
"install:codesandbox": "PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 yarn install --ignore-engines",
Expand Down

0 comments on commit b97ccb6

Please sign in to comment.