Skip to content

Commit

Permalink
Update check-json.js
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR authored Mar 27, 2023
1 parent 05dfb7f commit 2b34029
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions build/check-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ const path = require('node:path')
const process = require('node:process')
const picocolors = require('picocolors')


const fontJson = require(path.join(__dirname, '../font/bootstrap-icons.json'))
const jsonIconList = Object.keys(fontJson)

const iconsDir = path.join(__dirname, '../icons/');

const jsonIconList = Object.keys(fontJson)

(async () => {
try {
const basename = path.basename(__filename)
Expand All @@ -27,13 +26,15 @@ const iconsDir = path.join(__dirname, '../icons/');
const onlyInJson = jsonIconList.filter(i => !svgIconList.includes(i))
const onlyInSvg = svgIconList.filter(i => !jsonIconList.includes(i))

if(onlyInJson.length != 0 || onlyInSvg != 0) {
if(onlyInJson.length){
console.error(picocolors.red("Found additional icons in JSON:\n %s"), onlyInJson.join(", "))
if (onlyInJson.length !== 0 || onlyInSvg !== 0) {
if (onlyInJson.length > 0) {
console.error(picocolors.red('Found additional icons in JSON:\n %s'), onlyInJson.join(', '))
}
if(onlyInSvg.length){
console.error(picocolors.red("Found additional icons in SVG files:\n %s"), onlyInSvg.join(", "))

if (onlyInSvg.length > 0) {
console.error(picocolors.red('Found additional icons in SVG files:\n %s'), onlyInSvg.join(', '))
}

throw new Error('Mismatch between JSON and SVG files')
}

Expand Down

0 comments on commit 2b34029

Please sign in to comment.