build-icons-json.js 527 Bytes
Newer Older
Cole Bemis's avatar
Cole Bemis committed
1 2 3 4 5 6 7 8
import fs from 'fs';
import path from 'path';

import buildIconsObject from './build-icons-object';

const IN_DIR = path.resolve(__dirname, '../icons');
const OUT_FILE = path.resolve(__dirname, '../dist/icons.json');

Cole Bemis's avatar
Cole Bemis committed
9
console.log(`Building ${OUT_FILE}...`);
Cole Bemis's avatar
Cole Bemis committed
10 11 12 13 14 15 16 17 18 19

const svgFiles = fs
  .readdirSync(IN_DIR)
  .filter(file => path.extname(file) === '.svg');

const getSvg = svgFile => fs.readFileSync(path.join(IN_DIR, svgFile));

const icons = buildIconsObject(svgFiles, getSvg);

fs.writeFileSync(OUT_FILE, JSON.stringify(icons));