mirror of
https://github.com/tabler/tabler-icons.git
synced 2025-08-01 11:50:25 +02:00
check unicodes script
This commit is contained in:
34
.build/check-icons-unicodes.mjs
Normal file
34
.build/check-icons-unicodes.mjs
Normal file
@@ -0,0 +1,34 @@
|
||||
import glob from 'glob'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { ICONS_SRC_DIR } from './helpers.mjs'
|
||||
|
||||
let unicodes = []
|
||||
|
||||
glob(path.join(ICONS_SRC_DIR, '*.svg'), {}, function(er, files) {
|
||||
for (const i in files) {
|
||||
const file = files[i]
|
||||
|
||||
let svgFile = fs.readFileSync(file).toString()
|
||||
const matches = svgFile.match(/\nunicode: "?([a-f0-9.]+)"?/i)
|
||||
|
||||
if (matches[1]) {
|
||||
const unicode = matches[1]
|
||||
|
||||
console.log('unicode', unicode, unicodes.indexOf(unicode));
|
||||
|
||||
if (unicode && unicodes.indexOf(unicode) === -1) {
|
||||
unicodes.push(unicode)
|
||||
} else {
|
||||
throw new Error(`Unicode ${unicode} in icon ${file} already exists!`)
|
||||
}
|
||||
} else {
|
||||
throw new Error(`Icon ${file} don't have a unicode!`)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
console.log('unicodes', unicodes);
|
||||
})
|
||||
|
||||
|
@@ -18,7 +18,8 @@
|
||||
"changelog": "node ./.build/changelog.mjs",
|
||||
"changelog-commit": "node ./.build/changelog-commit.mjs",
|
||||
"changelog-image": "node ./.build/changelog-image.mjs",
|
||||
"update": "pnpm run update:icons-version && pnpm run update:icons-unicode",
|
||||
"check-unicodes": "node ./.build/check-icons-unicodes.mjs",
|
||||
"update": "pnpm run update:icons-version && pnpm run update:icons-unicode && pnpm run check-unicodes",
|
||||
"update:icons-version": "node ./.build/update-icons-version.mjs",
|
||||
"update:icons-unicode": "node ./.build/update-icons-unicode.mjs",
|
||||
"optimize": "node ./.build/optimize.mjs",
|
||||
|
Reference in New Issue
Block a user