forked from internetErik/gulp-htmlincluder
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
44 lines (33 loc) · 847 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
41
42
43
44
var through = require("through2"),
gutil = require("gulp-util"),
includer = require("./lib/htmlincluder");
module.exports = function (param) {
"use strict";
var that;
includer.initialize();
function htmlincluder() {
includer.buildHtml(function(file) {
var f = file.file;
f.contents = new Buffer(file.content);
that.push(f);
});
}
function aggregateFiles(file, enc, callback) {
that = this; //defined in scope of module
// Do nothing if no contents
if (file.isNull()) {
this.push(file);
return callback();
}
if (file.isStream()) {
this.emit("error",
new gutil.PluginError("gulp-htmlincluder", "Stream content is not supported"));
return callback();
}
if (file.isBuffer()) {
includer.hashFile(file);
}
return callback();
}
return through.obj(aggregateFiles, htmlincluder);
};