UNPKG

material-icons

Version:

Material design icon font and CSS framework for self hosting the icons.

41 lines (34 loc) 955 B
const fs = require('fs') const path = require('path') const { EOL } = require('os') const SRC = path.resolve(__dirname + '/../iconfont/codepoints') const DST_JSON = path.resolve(__dirname + '/../iconfont/codepoints.json') const DST_SCSS = path.resolve(__dirname + '/../iconfont/codepoints.scss') const lines = fs .readFileSync(SRC) .toString() .split(EOL) const codepoints = {} let map = '' lines.forEach((line) => { const [name, codepoint] = line .trim() .split(' ') .map((v) => v.trim()) if (!name || !codepoint) { return } codepoints[name] = codepoint }) for (const [name, codepoint] of Object.entries(codepoints)) { map += ` "${name}": ${codepoint},${EOL}` } map = map.replace(/,\s*$/, '') const mapName = '$material-icons-codepoints' map = `${mapName}: () !default; ${mapName}: map-merge(( ${map} ), ${mapName}); ` fs.writeFileSync(DST_JSON, JSON.stringify(codepoints, null, 2)) fs.writeFileSync(DST_SCSS, map)