-
Notifications
You must be signed in to change notification settings - Fork 8
/
example-stream.js
40 lines (29 loc) · 848 Bytes
/
example-stream.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
var SpriteData = require("./index");
var sprite = require("./lib/svg-sprite");
var vfs = require("vinyl-fs");
var config = {
common: "icon",
dims: true,
layout: "diagonal",
render: {
css: true
}
};
function svgSprites(config) {
var spriter = new SpriteData(config);
return require("through2").obj(function (file, enc, cb) {
// Add the file from the stream
spriter.add(file.path, file.contents.toString());
cb(null);
}, function (cb) {
// Compile
spriter.compile(function (err, svg) {
// use the data to create some in-memory files and throw em down stream
console.log(svg);
});
return true;
});
}
vfs.src(["test/fixtures/*.svg"])
.pipe(svgSprites(config))
.pipe(vfs.dest("test/output"));