Skip to content

Commit

Permalink
fix: implement iconExists helper
Browse files Browse the repository at this point in the history
  • Loading branch information
snickbit committed Jun 4, 2022
1 parent d1d6d87 commit 7d8313c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/actions/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ export default async argv => cli(argv)
let [icon, ...aliases] = item.split(',')

let iconName = cleanIconName(icon)
const reg = new RegExp(`^fa[a-z]?:(${iconName})$`)
if (!config.icons.find(i => reg.test(i))) {
if (!iconExists(iconName)) {
const iconQuery = gql`
query ($version: String!, $query: String!) {
search(version: $version, query: $query, first: 15) {id, styles, label}
Expand Down Expand Up @@ -75,10 +74,11 @@ export default async argv => cli(argv)
iconName = iconName.replace(/fa:/, 'fab:')
}

if (!config.icons.includes(iconName)) {
config.icons.push(iconName)
$out.v().success(`Added icon {cyan}${iconName}{/cyan}`)
changes.icons++
if (!iconExists(iconName)) {
config.icons.push(iconName)
$out.v().success(`Added icon {cyan}${iconName}{/cyan}`)
changes.icons++
}
}
}
} else {
Expand Down

0 comments on commit 7d8313c

Please sign in to comment.