Skip to content

Commit

Permalink
Alias feature detection includes icons package
Browse files Browse the repository at this point in the history
  • Loading branch information
robmadole committed Jul 2, 2022
1 parent eb6f6f5 commit 97e6518
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
"react": ">=17.x",
"react-dom": "^17.0.2",
"react-test-renderer": "^17.0.2",
"rollup": "^2.64.0"
"rollup": "^2.64.0",
"semver": "^7.3.7"
},
"dependencies": {
"prop-types": "^15.8.1"
Expand Down
13 changes: 12 additions & 1 deletion src/components/__fixtures__/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,24 @@ import React from 'react'
import FontAwesomeIcon from '../FontAwesomeIcon'
import renderer from 'react-test-renderer'
import { parse } from '@fortawesome/fontawesome-svg-core'
import semver from 'semver'

const SVG_ICONS_VERSION = semver.parse(
require('@fortawesome/free-solid-svg-icons/package.json').version
)

export const REFERENCE_ICON_BY_STYLE = 0x00
export const ICON_ALIASES = 0x01
export const REFERENCE_ICON_USING_STRING = 0x02

export function coreHasFeature (feature) {
if (feature === REFERENCE_ICON_BY_STYLE || feature === ICON_ALIASES || feature === REFERENCE_ICON_USING_STRING) {
if (feature === ICON_ALIASES) {
// Aliases were not introduced until version 6 so we need to check the
// installed free-solid-svg-icons package as well.
return parse.icon && SVG_ICONS_VERSION.major >= 6
}

if (feature === REFERENCE_ICON_BY_STYLE || feature === REFERENCE_ICON_USING_STRING) {
return parse.icon
}
}
Expand Down

0 comments on commit 97e6518

Please sign in to comment.