UNPKG

664 BJavaScriptView Raw
1"use strict";
2
3var gutil = require('gulp-util');
4var through = require('through2');
5
6
7var PLUGIN_NAME = 'gulp-inline-ng2-template';
8
9module.exports = exports = function inline(options) {
10 return through.obj(function (file, enc, cb) {
11 if (file.isNull()) {
12 cb(null, file);
13 return;
14 }
15
16 if (file.isStream()) {
17 cb(new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported'));
18 return;
19 }
20
21 try {
22 file.contents = new Buffer(require('./parser')(file, options));
23
24 this.push(file);
25 } catch (err) {
26 this.emit('error', new gutil.PluginError(PLUGIN_NAME, err, {fileName: file.path}));
27 }
28
29 cb();
30 });
31};