-
Notifications
You must be signed in to change notification settings - Fork 0
/
icons.js
37 lines (35 loc) · 1.01 KB
/
icons.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const webfontsGenerator = require('webfonts-generator');
const base64 = require('./scripts/base64');
const path = require('path');
const _ = require('lodash');
const fs = require('fs');
// App root
const appDir = __dirname;
// Read icons configuration file
let config = JSON.parse(fs.readFileSync(path.join(appDir, 'icons.json')));
let defaultPath = config.path;
let icons = config.icons;
let iconsFiles = icons.map(icon => (icon.path ? icon.path : defaultPath) + icon.svg);
webfontsGenerator(
{
files: iconsFiles,
dest: config.dest,
fontName: config.fontName,
cssDest: 'scss/_font.scss',
cssTemplate: 'scss/font.hbs',
rename: filePath => {
let fileName = path.basename(filePath);
let name = _.result(_.find(icons, icon => path.basename(icon.svg) === fileName), 'name');
return name;
},
types: ['svg', 'woff', 'ttf']
},
error => {
if (error) {
console.error(error);
process.exit(1);
}
base64.encode(config, 'scss/_font.scss');
}
);
process.exit();