-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
34 lines (26 loc) · 931 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
var through = require('through2');
var gutil = require('gulp-util');
var angularjsx = require("angular-jsx");
var PluginError = gutil.PluginError;
// consts
const PLUGIN_NAME = 'gulp-angular-jsx';
// plugin level function (dealing with files)
function gulpAngularJsx() {
// creating a stream through which each file will pass
var stream = through.obj(function(file, enc, cb) {
if (file.isStream()) {
this.emit('error', new PluginError(PLUGIN_NAME, 'Streams are not supported!'));
return cb();
}
if (file.isBuffer()) {
file.contents = new Buffer(angularjsx.convert(file.contents));
}
// make sure the file goes through the next gulp plugin
this.push(file);
// tell the stream engine that we are done with this file
cb();
});
// returning the file stream
return stream;
};
module.exports = gulpAngularJsx;