@sequencemedia/css-purge
Version:
A CSS tool written in Node JS as a command line app or library for the purging, burning, reducing, shortening, compressing, cleaning, trimming and formatting of duplicate, extra, excess or bloated CSS.
34 lines (29 loc) • 724 B
JavaScript
import parseCssFont from 'parse-css-font'
import {
handleCssParseFontError
} from '#utils/errors'
export default function getValueOfFontProp (font, property, position) {
if (font) {
try {
const properties = parseCssFont(font)
const value = properties[property]
return (
value === 'normal'
? ''
: value
)
} catch ({ message }) {
const m = message.toLowerCase()
if (m.includes('missing required font-size')) {
return 'check size'
} else {
if (m.includes('missing required font-family')) {
return 'check family'
} else {
handleCssParseFontError(position)
}
}
}
}
return ''
}