Skip to content

Commit

Permalink
Merge pull request #82 from TheDancingCode/issue-81
Browse files Browse the repository at this point in the history
Drop dependency on deprecated `gulp-util`
  • Loading branch information
James K Nelson authored Feb 3, 2018
2 parents 05a6de8 + 91ac7f1 commit 5d33e2f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module.exports = plugin;

var path = require('path');
var gutil = require('gulp-util');
var PluginError = require('plugin-error');
var through = require('through2');

var utils = require('./utils');
Expand All @@ -29,7 +29,7 @@ function plugin(options) {
}

if (file.isStream()) {
this.emit('error', new gutil.PluginError('gulp-rev-replace', 'Streaming not supported'));
this.emit('error', new PluginError('gulp-rev-replace', 'Streaming not supported'));
return cb();
}

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
},
"license": "MIT",
"dependencies": {
"gulp-util": "^3.0.7",
"plugin-error": "^0.1.2",
"through2": "^2.0.0"
},
"devDependencies": {
"event-stream": "^3.2.2",
"gulp-filter": "^3.0.1",
"gulp-rev": "^6.0.1",
"mocha": "^2.3.4"
"mocha": "^2.3.4",
"vinyl": "^2.1.0"
}
}
48 changes: 24 additions & 24 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

var assert = require('assert');
var filter = require('gulp-filter');
var gutil = require('gulp-util');
var Vinyl = require('vinyl');
var path = require('path');
var rev = require('gulp-rev');
var es = require('event-stream');
Expand Down Expand Up @@ -61,19 +61,19 @@ it('should by default replace filenames in .css and .html files', function (cb)
cb();
});

filesToRevFilter.write(new gutil.File({
filesToRevFilter.write(new Vinyl({
path: path.join('css', 'style.css'),
contents: new Buffer(cssFileBody)
}));
filesToRevFilter.write(new gutil.File({
filesToRevFilter.write(new Vinyl({
path: path.join('fonts', 'font.svg'),
contents: new Buffer(svgFileBody)
}));
filesToRevFilter.write(new gutil.File({
filesToRevFilter.write(new Vinyl({
path: 'images/image.png',
contents: new Buffer('PNG')
}));
filesToRevFilter.write(new gutil.File({
filesToRevFilter.write(new Vinyl({
path: 'index.html',
contents: new Buffer(htmlFileBody)
}));
Expand Down Expand Up @@ -105,11 +105,11 @@ it('should not replace filenames in extensions not in replaceInExtensions', func
cb();
});

filesToRevFilter.write(new gutil.File({
filesToRevFilter.write(new Vinyl({
path: 'css\\style.css',
contents: new Buffer(cssFileBody)
}));
filesToRevFilter.write(new gutil.File({
filesToRevFilter.write(new Vinyl({
path: 'index.html',
contents: new Buffer(htmlFileBody)
}));
Expand Down Expand Up @@ -141,11 +141,11 @@ it('should not canonicalize URIs when option is off', function (cb) {
cb();
});

filesToRevFilter.write(new gutil.File({
filesToRevFilter.write(new Vinyl({
path: 'css\\style.css',
contents: new Buffer(cssFileBody)
}));
filesToRevFilter.write(new gutil.File({
filesToRevFilter.write(new Vinyl({
path: 'index.html',
contents: new Buffer(htmlFileBody)
}));
Expand Down Expand Up @@ -177,11 +177,11 @@ it('should add prefix to path', function (cb) {
cb();
});

filesToRevFilter.write(new gutil.File({
filesToRevFilter.write(new Vinyl({
path: 'css/style.css',
contents: new Buffer(cssFileBody)
}));
filesToRevFilter.write(new gutil.File({
filesToRevFilter.write(new Vinyl({
path: 'index.html',
contents: new Buffer(htmlFileBody)
}));
Expand Down Expand Up @@ -213,15 +213,15 @@ it('should stop at first longest replace', function(cb) {
cb();
});

filesToRevFilter.write(new gutil.File({
filesToRevFilter.write(new Vinyl({
path: 'style.css',
contents: new Buffer(cssFileBody)
}));
filesToRevFilter.write(new gutil.File({
filesToRevFilter.write(new Vinyl({
path: 'nopestyle.css',
contents: new Buffer('boooooo')
}));
filesToRevFilter.write(new gutil.File({
filesToRevFilter.write(new Vinyl({
path: 'script.js',
contents: new Buffer(jsFileBody)
}));
Expand All @@ -232,13 +232,13 @@ it('should stop at first longest replace', function(cb) {
describe('manifest option', function () {
it('should replace filenames from manifest files', function (cb) {
var manifest = es.readArray([
new gutil.File({
new Vinyl({
path: '/project/rev-manifest.json',
contents: new Buffer(JSON.stringify({
'/css/style.css': '/css/style-12345.css'
}))
}),
new gutil.File({
new Vinyl({
path: '/project/rev-image-manifest.json',
contents: new Buffer(JSON.stringify({
'images/image.png': 'images/image-12345.png',
Expand Down Expand Up @@ -281,15 +281,15 @@ describe('manifest option', function () {
cb();
});

stream.write(new gutil.File({
stream.write(new Vinyl({
path: path.join('css', 'style.css'),
contents: new Buffer(cssFileBody)
}));
stream.write(new gutil.File({
stream.write(new Vinyl({
path: path.join('fonts', 'font.svg'),
contents: new Buffer(svgFileBody)
}));
stream.write(new gutil.File({
stream.write(new Vinyl({
path: 'index.html',
contents: new Buffer(htmlFileBody)
}));
Expand All @@ -299,7 +299,7 @@ describe('manifest option', function () {

it('should add prefix to path', function (cb) {
var manifest = es.readArray([
new gutil.File({
new Vinyl({
path: '/project/rev-manifest.json',
contents: new Buffer(JSON.stringify({
'/css/style.css': '/css/style-12345.css'
Expand All @@ -324,7 +324,7 @@ describe('manifest option', function () {
cb();
});

stream.write(new gutil.File({
stream.write(new Vinyl({
path: 'index.html',
contents: new Buffer(htmlFileBody)
}));
Expand Down Expand Up @@ -480,7 +480,7 @@ describe('utils.byLongestUnreved', function() {
describe('modifyUnreved and modifyReved options', function() {
it('should modify the names of reved and un-reved files', function(cb) {
var manifest = es.readArray([
new gutil.File({
new Vinyl({
path: '/project/rev-manifest.json',
contents: new Buffer(JSON.stringify({
'js/app.js.map': 'js/app-12345.js.map',
Expand Down Expand Up @@ -526,11 +526,11 @@ describe('modifyUnreved and modifyReved options', function() {
cb();
});

stream.write(new gutil.File({
stream.write(new Vinyl({
path: path.join('js', 'app.js'),
contents: new Buffer(jsFileBody)
}));
stream.write(new gutil.File({
stream.write(new Vinyl({
path: 'index.html',
contents: new Buffer(htmlFileBody)
}));
Expand Down

0 comments on commit 5d33e2f

Please sign in to comment.