-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
82 lines (63 loc) · 2.23 KB
/
test.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const fs = require('fs');
const path = require('path');
const EC = require('eight-colors');
const SFE = require('../lib');
const list = [
{
input: path.resolve(__dirname, '../node_modules/themify-icons/themify-icons/fonts/themify.svg'),
output: path.resolve(__dirname, 'output/themify-icons'),
getNameMap: function() {
const file = path.resolve(__dirname, '../node_modules/themify-icons/themify-icons/_icons.scss');
const content = fs.readFileSync(file, {
encoding: 'utf-8'
});
const nameMap = {};
content.split(/\r|\n/g).forEach((line) => {
const str = line.trim();
//console.log(str);
if (!str) {
return;
}
const name = str.split(':')[0].replace(/\.icon-/g, '');
//console.log(name);
const v = str.split('"')[1].split('"')[0];
const code = v.replace('\\', '');
const u = parseInt(code, 16);
const x = String.fromCharCode(u);
//console.log(u);
nameMap[x] = name;
});
//console.log(nameMap);
const total = EC.yellow(Object.keys(nameMap).length);
console.log('nameMap', total);
return nameMap;
},
onSVGItem: function(item) {
if (!item.d) {
return;
}
if (!this.nameMap) {
this.nameMap = this.getNameMap();
}
item.name = this.nameMap[item.unicode] || item['glyph-name'] || item.index;
return item;
}
},
// {
// //elementor-icons
// input: path.resolve(__dirname, 'input/eicons.svg'),
// output: path.resolve(__dirname, 'output/eicons')
// },
// {
// //androidicons
// input: path.resolve(__dirname, 'input/androidicons.svg'),
// output: path.resolve(__dirname, 'output/androidicons')
// },
{
input: path.resolve(__dirname, '../node_modules/icofont/dist/fonts/icofont.svg'),
output: path.resolve(__dirname, 'output/icofont')
}
];
list.forEach((item) => {
SFE(item);
});