mirror of
https://github.com/tabler/tabler-icons.git
synced 2025-08-19 12:21:39 +02:00
add aliases validator
This commit is contained in:
@@ -1,14 +1,15 @@
|
|||||||
import { globSync } from 'glob'
|
import { globSync } from 'glob'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import { basename } from 'path'
|
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'
|
import { join } from 'path'
|
||||||
|
|
||||||
let error = false
|
let error = false
|
||||||
|
|
||||||
const outlineIconsNames = globSync(join(ICONS_SRC_DIR, 'outline/*.svg')).map(i => basename(i, '.svg')),
|
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')),
|
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 = []
|
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) {
|
if (error) {
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user