apeman-react-icon
Version:
apeman react package for icon components.
30 lines (24 loc) • 565 B
JSX
/**
* @function _readAsset
*/
import fs from 'fs'
import path from 'path'
const assetDir = `${__dirname}/../asset`
/** @lends _readAsset */
function _readAsset (name) {
let filename = path.join(assetDir, name)
let exists = fs.existsSync && fs.existsSync(filename)
if (!exists) {
return null
}
let cache = _readAsset.cache[ filename ]
if (cache) {
return cache
}
let content = fs.readFileSync(filename).toString()
_readAsset.cache[ filename ] = content
return content
}
_readAsset.cache = {}
export default _readAsset