diff --git a/index.js b/index.js index 51ff71f..cdbb8c7 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,8 @@ var path = require('path'); var through = require('through'); var assign = require('object-assign'); var defaults = require('lodash.defaults'); -var gutil = require('gulp-util'); +var Vinyl = require('vinyl'); +var PluginError = require('plugin-error'); var Promise = require('bluebird'); var DEFAULT_OPTIONS = { fileName: 'busters.json', @@ -26,7 +27,7 @@ var OPTION_TYPES = { var hashesStore = {}; // options.fileName: { relativePath: hash } function error(msg) { - return new gutil.PluginError('gulp-buster', msg); + return new PluginError('gulp-buster', msg); } function hash(file, options) { @@ -90,13 +91,13 @@ module.exports = exports = function(options) { }).then(function(formatted) { if (typeof formatted !== 'string') throw error('Return/fulfill value of `options.formatter` must be a string'); - this.emit('data', new gutil.File({ + this.emit('data', new Vinyl({ path: path.join(process.cwd(), options.fileName), contents: new Buffer(formatted), })); this.emit('end'); }).catch(function(err) { - this.emit('error', err instanceof gutil.PluginError ? err : error(err)); + this.emit('error', err instanceof PluginError ? err : error(err)); }); } diff --git a/package.json b/package.json index 1887012..07247e6 100644 --- a/package.json +++ b/package.json @@ -26,10 +26,11 @@ }, "dependencies": { "bluebird": "^3.3.5", - "gulp-util": "^3.0.7", "lodash.defaults": "^4.0.1", "object-assign": "^4.0.1", - "through": "^2.3.8" + "plugin-error": "^1.0", + "through": "^2.3.8", + "vinyl": "^2.0" }, "engines": { "node": ">= 0.10" diff --git a/test/main.js b/test/main.js index 7fc89f3..936a61d 100644 --- a/test/main.js +++ b/test/main.js @@ -2,29 +2,30 @@ var bust = require('..'); var assign = require('object-assign'); -var gutil = require('gulp-util'); +var Vinyl = require('vinyl'); require('should'); var fileContentStr = 'foo'; var file2ContentStr = 'bar'; -var file = new gutil.File({ +var file = new Vinyl({ cwd: 'C:/users/ult/', base: 'C:/users/ult/test', path: 'C:/users/ult/test/file.js', contents: new Buffer(fileContentStr), }); -var file2 = new gutil.File({ +var file2 = new Vinyl({ cwd: 'C:/users/ult/', base: 'C:/users/ult/test', path: 'C:/users/ult/test/file2.js', contents: new Buffer(file2ContentStr), }); -var fileBinary = new gutil.File({ +var fileBinary = new Vinyl({ cwd: 'C:/users/ult/', base: 'C:/users/ult/test', path: 'C:/users/ult/test/file2.js', contents: new Buffer([0x80]), // `Buffer.from` is not supported in Node 0.10 }); +var PluginError = require('plugin-error'); var fileBustPath = bust._relativePath(file.cwd, '.', file.path); var fileBustPathRelative = bust._relativePath(file.cwd, 'test/', file.path); var file2BustPath = bust._relativePath(file2.cwd, '.', file2.path); @@ -41,7 +42,7 @@ beforeEach(bust._reset); describe('Configuration-independent internal methods', function() { describe('_error()', function() { it('should return an instance of PluginError', function() { - bust._error('err').should.be.an.instanceOf(gutil.PluginError); + bust._error('err').should.be.an.instanceOf(PluginError); }); }); @@ -106,7 +107,7 @@ describe('Core', function() { it('should bust two files into the same output file in the same stream', function(done) { var stream = bust(); stream.on('data', function(newFile) { - newFile.should.be.an.instanceOf(gutil.File); + newFile.should.be.an.instanceOf(Vinyl); newFile.should.have.property('path'); newFile.should.have.property('relative'); newFile.should.have.property('contents'); @@ -246,7 +247,7 @@ describe('Configuration options', function() { it('should emit an error when function does not return a string or promise', function(done) { var stream = bust({ algo: function() {} }); stream.on('error', function(err) { - err.should.be.an.instanceOf(gutil.PluginError); + err.should.be.an.instanceOf(PluginError); done(); }); stream.end(file); @@ -259,7 +260,7 @@ describe('Configuration options', function() { }, }); stream.on('error', function(err) { - err.should.be.an.instanceOf(gutil.PluginError); + err.should.be.an.instanceOf(PluginError); done(); }); stream.end(file); @@ -370,7 +371,7 @@ describe('Configuration options', function() { it('should emit an error when function does not return a string or promise', function(done) { var stream = bust({ formatter: function() {} }); stream.on('error', function(err) { - err.should.be.an.instanceOf(gutil.PluginError); + err.should.be.an.instanceOf(PluginError); done(); }); stream.end(file); @@ -383,7 +384,7 @@ describe('Configuration options', function() { }, }); stream.on('error', function(err) { - err.should.be.an.instanceOf(gutil.PluginError); + err.should.be.an.instanceOf(PluginError); done(); }); stream.end(file);