-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
executable file
·40 lines (32 loc) · 1011 Bytes
/
index.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
'use strict';
const path = require('path');
const gutil = require('gulp-util');
const through = require('through2');
const blast = require('font-blast');
const yaml = require('js-yaml');
const fs = require('fs');
module.exports = function (dest, opts) {
return through.obj(function (file, enc, cb) {
if (file.isNull()) {
cb(null, file);
return;
}
if (file.isStream()) {
cb(new gutil.PluginError('gulp-font-blast', 'Streaming not supported'));
return;
}
try {
var iconnames = require('js-yaml').safeLoad(fs.readFileSync(file.base + "icons.yml", 'utf8')).icons;
var convertFilenames = {};
var iconNamingConventions = yaml.safeLoad(file.base + "icons.yml").icons;
iconnames.forEach(function (icon) {
convertFilenames[icon.unicode] = icon.id;
});
blast(file.path.toString(), dest, {filenames: convertFilenames});
} catch (err) {
this.emit('error', new gutil.PluginError('gulp-<%= pluginName %>', err));
}
cb();
});
};
module.exports.blast = blast;