-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
40 lines (33 loc) · 853 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
import File from 'vinyl';
import { Transform } from 'stream';
import { stream } from 'favicons';
import pipe from 'multipipe';
// in future node versions can use https://nodejs.org/api/stream.html#streamcomposestreams
class Faviconify extends Transform {
constructor () {
super({ objectMode: true });
}
_transform ({ contents }, _enc, cb) {
this.push(contents);
cb();
}
}
class Vinylify extends Transform {
constructor () {
super({ objectMode: true });
}
_transform ({ name: path, contents }, _enc, cb) {
this.push(new File({
path,
contents
}));
cb();
}
}
export { config } from 'favicons';
export default (options, handleHTML) =>
pipe(
new Faviconify(),
stream(options, handleHTML),
new Vinylify()
);