diff --git a/index.js b/index.js index e14da6b..8452d23 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,8 @@ 'use strict'; -var gutil = require('gulp-util'); var through = require('through2'); var tpl = require('lodash.template'); -var PluginError = gutil.PluginError; +var PluginError = require('plugin-error'); +var replaceExtension = require('replace-ext'); var PLUGIN_NAME = 'gulp-template-compile'; @@ -33,7 +33,7 @@ module.exports = function (options) { var namespace = getNamespaceDeclaration(options.namespace || 'JST'); var IIFE_start = options.IIFE !== false ? '(function() {\n':''; var IIFE_end = options.IIFE !== false ? '})();':''; - + var templateHeader = IIFE_start + namespace.declaration; var NSwrapper = '\n\n' + namespace.namespace + '["'+ name.replace(/\\/g, '/') +'"] = '; @@ -61,7 +61,7 @@ module.exports = function (options) { var compiled = compiler(file); file.contents = new Buffer(compiled); - file.path = gutil.replaceExtension(file.path, '.js'); + file.path = replaceExtension(file.path, '.js'); } catch (err) { this.emit('error', new PluginError(PLUGIN_NAME, err, {fileName: filePath})); return callback(); diff --git a/package.json b/package.json index 5e6a450..a1debd0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gulp-template-compile", - "version": "1.3.1", + "version": "1.3.2", "description": "Gulp task to precompile lodash templates", "main": "index.js", "author": { @@ -31,11 +31,13 @@ ], "license": "MIT", "dependencies": { - "gulp-util": "~3.0.0", - "lodash.template": "~4.2.5", - "through2": "~0.5.1" + "lodash.template": "~4.4.0", + "plugin-error": "^1.0.1", + "replace-ext": "^1.0.0", + "through2": "~0.6.1" }, "devDependencies": { - "mocha": "*" + "mocha": "*", + "vinyl": "^2.2.0" } } diff --git a/test.js b/test.js index 988e036..a1f5a78 100644 --- a/test.js +++ b/test.js @@ -1,6 +1,6 @@ 'use strict'; var assert = require('assert'); -var gutil = require('gulp-util'); +var Vinyl = require('vinyl'); var tpl = require('./index'); it('should precompile lodash templates', function(cb) { @@ -15,7 +15,7 @@ it('should precompile lodash templates', function(cb) { cb(); }); - stream.write(new gutil.File({ + stream.write(new Vinyl({ base: __dirname, path: __dirname + '/fixture/fixture.html', contents: new Buffer('

<%= test %>

') @@ -36,7 +36,7 @@ it('should support supplying custom name in a callback', function (cb) { cb(); }); - stream.write(new gutil.File({ + stream.write(new Vinyl({ base: __dirname, path: __dirname + '/fixture/fixture.html', contents: new Buffer('

<%= test %>

') @@ -55,7 +55,7 @@ it('should support supplying a custom namespace', function (cb) { cb(); }); - stream.write(new gutil.File({ + stream.write(new Vinyl({ base: __dirname, path: __dirname + '/fixture/fixture.html', contents: new Buffer('

<%= test %>

') @@ -74,7 +74,7 @@ it('should support dot paths in namespace', function (cb) { cb(); }); - stream.write(new gutil.File({ + stream.write(new Vinyl({ base: __dirname, path: __dirname + '/fixture/fixture.html', contents: new Buffer('

<%= test %>

') @@ -96,7 +96,7 @@ it('shouldn´t generate IIFE encapsulation', function(cb) { cb(); }); - stream.write(new gutil.File({ + stream.write(new Vinyl({ base: __dirname, path: __dirname + '/fixture/fixture.html', contents: new Buffer('

<%= test %>

') @@ -118,7 +118,7 @@ it('should generate IIFE encapsulation with specific configuration', function(cb cb(); }); - stream.write(new gutil.File({ + stream.write(new Vinyl({ base: __dirname, path: __dirname + '/fixture/fixture.html', contents: new Buffer('

<%= test %>

') @@ -137,9 +137,9 @@ it('should generate IIFE encapsulation without configuration', function(cb) { cb(); }); - stream.write(new gutil.File({ + stream.write(new Vinyl({ base: __dirname, path: __dirname + '/fixture/fixture.html', contents: new Buffer('

<%= test %>

') })); -}); \ No newline at end of file +});