Skip to content

Commit

Permalink
Fix: Replace vinyl-filter-since with own working implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
yocontra authored and phated committed Nov 28, 2017
1 parent 78865bf commit 8e15c49
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 18 deletions.
16 changes: 16 additions & 0 deletions lib/filterSince.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

var filter = require('through2-filter');

module.exports = function(d) {
var isValid = typeof d === 'number' ||
d instanceof Number ||
d instanceof Date;

if (!isValid) {
throw new Error('expected since option to be a date or a number');
}
return filter.obj(function(file){
return file.stat && file.stat.mtime > d;
});
};
2 changes: 1 addition & 1 deletion lib/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var File = require('vinyl');
var duplexify = require('duplexify');
var merge = require('merge-stream');
var sourcemaps = require('gulp-sourcemaps');
var filterSince = require('vinyl-filter-since');
var filterSince = require('../filterSince');
var isValidGlob = require('is-valid-glob');

var getContents = require('./getContents');
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"strip-bom": "^2.0.0",
"strip-bom-stream": "^1.0.0",
"through2": "^2.0.0",
"vinyl": "^0.5.0",
"vinyl-filter-since": "^2.0.2"
"through2-filter": "^2.0.0",
"vinyl": "^0.5.0"
},
"devDependencies": {
"buffer-equal": "^0.0.1",
Expand Down
28 changes: 13 additions & 15 deletions test/dest.js
Original file line number Diff line number Diff line change
Expand Up @@ -872,23 +872,21 @@ describe('dest stream', function() {
stream.end();
});

['end', 'finish'].forEach(function(eventName) {
it('should emit ' + eventName + ' event', function(done) {
var srcPath = path.join(__dirname, './fixtures/test.coffee');
var stream = vfs.dest('./out-fixtures/', {cwd: __dirname});

stream.once(eventName, function() {
done();
});
it('should emit finish event', function(done) {
var srcPath = path.join(__dirname, './fixtures/test.coffee');
var stream = vfs.dest('./out-fixtures/', {cwd: __dirname});

var file = new File({
path: srcPath,
cwd: __dirname,
contents: new Buffer("1234567890")
});
stream.once('finish', function() {
done();
});

stream.write(file);
stream.end();
var file = new File({
path: srcPath,
cwd: __dirname,
contents: new Buffer("1234567890")
});

stream.write(file);
stream.end();
});
});

0 comments on commit 8e15c49

Please sign in to comment.