summaryrefslogtreecommitdiffstats
path: root/build/check-icons.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-04-07 12:22:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-04-07 12:22:19 +0000
commit4ec9afcefb2b7817a7a733e1bc9777a29c350ba4 (patch)
tree85313cb1a727ca829d93bb09299af26a4c247c54 /build/check-icons.js
parentAdding upstream version 1.10.3+dfsg. (diff)
downloadbootstrap-icons-4ec9afcefb2b7817a7a733e1bc9777a29c350ba4.tar.xz
bootstrap-icons-4ec9afcefb2b7817a7a733e1bc9777a29c350ba4.zip
Adding upstream version 1.10.4+dfsg.upstream/1.10.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'build/check-icons.js')
-rwxr-xr-xbuild/check-icons.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/build/check-icons.js b/build/check-icons.js
new file mode 100755
index 0000000..73f1a5b
--- /dev/null
+++ b/build/check-icons.js
@@ -0,0 +1,59 @@
+#!/usr/bin/env node
+
+'use strict'
+
+const fs = require('node:fs').promises
+const path = require('node:path')
+const process = require('node:process')
+const picocolors = require('picocolors')
+
+const fontJsonPath = path.join(__dirname, '../font/bootstrap-icons.json')
+const iconsDir = path.join(__dirname, '../icons/')
+
+;(async () => {
+ try {
+ const basename = path.basename(__filename)
+ const timeLabel = picocolors.cyan(`[${basename}] finished`)
+
+ console.log(picocolors.cyan(`[${basename}] started`))
+ console.time(timeLabel)
+
+ const fontJsonString = await fs.readFile(fontJsonPath, 'utf8')
+ const fontJson = JSON.parse(fontJsonString)
+ const svgFiles = await fs.readdir(iconsDir)
+
+ const jsonIconList = Object.keys(fontJson)
+ const svgIconList = svgFiles.map(svg => path.basename(svg, path.extname(svg)))
+
+ const onlyInJson = jsonIconList.filter(icon => !svgIconList.includes(icon))
+ const onlyInSvg = svgIconList.filter(icon => !jsonIconList.includes(icon))
+
+ if (onlyInJson.length === 0 || onlyInSvg === 0) {
+ console.log(picocolors.green('Success, found no differences!'))
+ console.timeEnd(timeLabel)
+
+ return
+ }
+
+ if (onlyInJson.length > 0) {
+ console.error(picocolors.red(`Found additional icons in ${fontJsonPath}:`))
+
+ for (const icon of onlyInJson) {
+ console.log(` - ${picocolors.red(icon)}`)
+ }
+ }
+
+ if (onlyInSvg.length > 0) {
+ console.error(picocolors.red('Found additional icons in SVG files:'))
+
+ for (const icon of onlyInSvg) {
+ console.log(` - ${picocolors.red(icon)}`)
+ }
+ }
+
+ process.exit(1)
+ } catch (error) {
+ console.error(error)
+ process.exit(1)
+ }
+})()