1
0
mirror of https://github.com/tabler/tabler-icons.git synced 2025-08-01 11:50:25 +02:00

add aliases validator

This commit is contained in:
codecalm
2024-02-28 00:02:45 +01:00
parent 4e83898467
commit 3c8b36e8e4

View File

@@ -1,14 +1,15 @@
import { globSync } from 'glob'
import fs from 'fs'
import { basename } from 'path'
import { ICONS_SRC_DIR, iconTemplate, parseMatter, types, getArgvs } from './helpers.mjs'
import { HOME_DIR, ICONS_SRC_DIR, iconTemplate, parseMatter, types, getArgvs } from './helpers.mjs'
import { join } from 'path'
let error = false
const outlineIconsNames = globSync(join(ICONS_SRC_DIR, 'outline/*.svg')).map(i => basename(i, '.svg')),
filledIconsNames = globSync(join(ICONS_SRC_DIR, 'filled/*.svg')).map(i => basename(i, '.svg')),
argvs = getArgvs();
argvs = getArgvs(),
aliases = JSON.parse(fs.readFileSync(join(HOME_DIR, 'aliases.json'), 'utf-8'));
let unicodes = []
@@ -76,6 +77,16 @@ types.forEach(type => {
})
})
// check aliases
Object.entries(aliases).forEach(([type, replacers]) => {
Object.entries(replacers).forEach(([icon, alias]) => {
if (!fs.existsSync(join(ICONS_SRC_DIR, type, `${alias}.svg`))) {
console.log(`Alias ${icon} for ${alias} in ${type} doesn't exists`)
error = true
}
})
})
if (error) {
process.exit(1)
} else {