-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (28 loc) · 833 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
'use strict';
var gutil = require('gulp-util');
var through = require('through2');
var path = require('path');
var fs = require('fs');
var File = gutil.File;
module.exports = function (options) {
return through.obj(function (file, enc, cb){
if (file.isNull()) {
this.push(file);
return cb();
}
if (file.isStream()) {
this.emit('error', new gutil.PluginError('gulp-ng-replace-directive-template', 'Streaming not supported'));
return cb();
}
var fileContent = String(file.contents.toString());
var content = '';
options.params.forEach(function(param){
var fileCont = !content ? fileContent : content;
content = fileCont.replace('<' + param, '<div '+ param);
content = content.replace('</' + param +'>', '</div>');
});
file.contents = new Buffer(content);
this.push(file);
cb();
});
};