Skip to content

Commit

Permalink
validate icons comment pr
Browse files Browse the repository at this point in the history
  • Loading branch information
codecalm committed Mar 13, 2024
1 parent 6fb8a35 commit 11e9c82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions .build/validate-icons.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ types.forEach(type => {
const iconContent = fs.readFileSync(icon, 'utf-8')

if (!iconContent.includes(iconTemplate(type))) {
console.log(`Icon ${icon} is not properly formatted`)
console.log(`Icon ${icon} is not properly formatted\n`)
error = true
}

if (!iconContent.includes('<!--') || !iconContent.includes('-->')) {
console.log(`Icon ${icon} has no metadata`)
console.log(`Icon ${icon} has no metadata\n`)
error = true
}

Expand All @@ -38,33 +38,33 @@ types.forEach(type => {

if (data.unicode) {
if (unicodes.indexOf(data.unicode) !== -1) {
console.log(`Icon ${icon} has duplicate unicode "${data.unicode}"`)
console.log(`Icon ${icon} has duplicate unicode "${data.unicode}"\n`)
error = true
}

if (data.unicode.length !== 4) {
console.log(`Icon ${icon} has invalid unicode "${data.unicode}"`)
console.log(`Icon ${icon} has invalid unicode "${data.unicode}"\n`)
error = true
}

// check duplicates in tags
if (duplicateExists(data.tags || [])) {
console.log(`Icon ${icon} has duplicate tags`)
console.log(`Icon ${icon} has duplicate tags\n`)
error = true
}

unicodes.push(data.unicode)
} else if (argvs.hard) {
console.log(`Icon ${icon} has no unicode`)
console.log(`Icon ${icon} has no unicode\n`)
error = true
}

if (argvs.hard && !data.version) {
console.log(`Icon ${icon} has no version`)
console.log(`Icon ${icon} has no version\n`)
error = true
}
} catch (e) {
console.log(`Icon ${icon} has invalid metadata`)
console.log(`Icon ${icon} has invalid metadata\n`)
error = true
}
})
Expand All @@ -81,7 +81,7 @@ types.forEach(type => {
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`)
console.log(`Alias ${icon} for ${alias} in ${type} doesn't exists\n`)
error = true
}
})
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-icons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

- name: Validate icons
id: validate
run: pnpm run --silent validate >> ./comment-markup.md
run: echo \`\`\``pnpm run --silent validate`\`\`\` >> ./comment-markup.md

- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
Expand Down

0 comments on commit 11e9c82

Please sign in to comment.