gulp-dotify
Advanced tools
Comparing version 0.1.1 to 0.1.2
22
index.js
@@ -8,3 +8,3 @@ var through = require('through2'); | ||
const PLUGIN_NAME = 'gulp-templatify'; | ||
const PLUGIN_NAME = 'gulp-dotify'; | ||
@@ -46,11 +46,15 @@ function getTemplateName(root, name, extension, separator) { | ||
if (error) { | ||
throw new PluginError(PLUGIN_NAME, error); | ||
this.emit('error', new PluginError(PLUGIN_NAME, error)); | ||
} | ||
var name = getTemplateName(options.root, file.path, options.extension, options.separator); | ||
var code = getTemplateCode(contents); | ||
file.contents = new Buffer([options.dictionary, '["', name, '"] = ', code, ';'].join('')); | ||
this.push(file); | ||
return callback(); | ||
try { | ||
var name = getTemplateName(options.root, file.path, options.extension, options.separator); | ||
var code = getTemplateCode(contents); | ||
file.contents = new Buffer([options.dictionary, '["', name, '"] = ', code, ';'].join('')); | ||
this.push(file); | ||
return callback(); | ||
} | ||
catch (exception) { | ||
this.emit('error', new PluginError(PLUGIN_NAME, exception)); | ||
} | ||
}.bind(this); | ||
@@ -57,0 +61,0 @@ |
{ | ||
"name": "gulp-dotify", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"repository": "https://github.com/titarenko/gulp-dotify", | ||
@@ -15,3 +15,4 @@ "description": "Gulp plugin for precompilation of doT templates.", | ||
"gulp", | ||
"plugin" | ||
"plugin", | ||
"gulpplugin" | ||
], | ||
@@ -18,0 +19,0 @@ "author": "Constantin Titarenko", |
@@ -24,2 +24,25 @@ var dotify = require('../'); | ||
}); | ||
it('should not throw errors inside a stream', function (done) { | ||
var stream = dotify(); | ||
stream.on('end', function () { | ||
done(); | ||
}); | ||
stream.on('error', function (e) { | ||
e.message.should.eql('Unexpected token ='); | ||
done(); | ||
}); | ||
var file = new gutil.File({ | ||
path: 'name.html', | ||
cwd: './', | ||
base: './', | ||
contents: new Buffer('<div>{{!= it.name }}</div>') | ||
}); | ||
stream.write(file); | ||
stream.end(); | ||
}); | ||
}); |
5195
100