glob-stream
Advanced tools
Comparing version 3.1.12 to 3.1.13
74
index.js
@@ -5,4 +5,3 @@ /*jslint node: true */ | ||
var through = require('through'); | ||
var map = require('map-stream'); | ||
var through2 = require('through2'); | ||
var Combine = require('ordered-read-streams'); | ||
@@ -16,27 +15,2 @@ var unique = require('unique-stream'); | ||
var isMatch = function(file, opt, pattern) { | ||
if (typeof pattern === 'string') return minimatch(file.path, pattern, opt); | ||
if (pattern instanceof RegExp) return pattern.test(file.path); | ||
return true; // unknown glob type? | ||
}; | ||
var isNegative = function(pattern) { | ||
if (typeof pattern !== 'string') return true; | ||
if (pattern[0] === '!') return true; | ||
return false; | ||
}; | ||
var isPositive = function(pattern) { | ||
return !isNegative(pattern); | ||
}; | ||
var unrelative = function(cwd, glob) { | ||
var mod = ''; | ||
if (glob[0] === '!') { | ||
mod = glob[0]; | ||
glob = glob.slice(1); | ||
} | ||
return mod+path.resolve(cwd, glob); | ||
}; | ||
var gs = { | ||
@@ -65,6 +39,6 @@ // creates a stream for a single glob or filter | ||
// create stream and map events from globber to it | ||
var stream = through(); | ||
var stream = through2.obj(negatives.length ? filterNegatives : undefined); | ||
globber.on('error', stream.emit.bind(stream, 'error')); | ||
globber.on('end', function(){ | ||
globber.on('end', function(/* some args here so can't use bind directly */){ | ||
stream.end(); | ||
@@ -80,12 +54,12 @@ }); | ||
if (negatives.length === 0) return stream; // no filtering needed | ||
return stream; | ||
// stream to check against negatives | ||
var filterStream = map(function(filename, cb) { | ||
function filterNegatives(filename, enc, cb) { | ||
var matcha = isMatch.bind(null, filename, opt); | ||
if (negatives.every(matcha)) return cb(null, filename); // pass | ||
cb(); // ignore | ||
}); | ||
return stream.pipe(filterStream); | ||
if (negatives.every(matcha)) { | ||
cb(null, filename); // pass | ||
} else { | ||
cb(); // ignore | ||
} | ||
} | ||
}, | ||
@@ -123,2 +97,28 @@ | ||
function isMatch(file, opt, pattern) { | ||
if (typeof pattern === 'string') return minimatch(file.path, pattern, opt); | ||
if (pattern instanceof RegExp) return pattern.test(file.path); | ||
return true; // unknown glob type? | ||
} | ||
function isNegative(pattern) { | ||
if (typeof pattern !== 'string') return true; | ||
if (pattern[0] === '!') return true; | ||
return false; | ||
} | ||
function isPositive(pattern) { | ||
return !isNegative(pattern); | ||
} | ||
function unrelative(cwd, glob) { | ||
var mod = ''; | ||
if (glob[0] === '!') { | ||
mod = glob[0]; | ||
glob = glob.slice(1); | ||
} | ||
return mod+path.resolve(cwd, glob); | ||
} | ||
module.exports = gs; |
{ | ||
"name": "glob-stream", | ||
"description": "File system globs as a stream", | ||
"version": "3.1.12", | ||
"version": "3.1.13", | ||
"homepage": "http://github.com/wearefractal/glob-stream", | ||
@@ -15,4 +15,3 @@ "repository": "git://github.com/wearefractal/glob-stream.git", | ||
"unique-stream": "^1.0.0", | ||
"through": "^2.3.4", | ||
"map-stream": "^0.1.0" | ||
"through2": "^0.5.1" | ||
}, | ||
@@ -19,0 +18,0 @@ "devDependencies": { |
var gs = require('../'); | ||
var through = require('through'); | ||
var through2 = require('through2'); | ||
var should = require('should'); | ||
@@ -49,9 +49,11 @@ require('mocha'); | ||
var stream = gs.create('./fixtures/stuff/*.dmc', {cwd: __dirname}); | ||
var wrapper = stream.pipe(through(function(data){ | ||
var wrapper = stream.pipe(through2.obj(function(data, enc, cb){ | ||
this.pause(); | ||
setTimeout(function(){ | ||
this.queue(data); | ||
this.push(data); | ||
cb(); | ||
this.resume(); | ||
}.bind(this), 500); | ||
})); | ||
@@ -58,0 +60,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6
478
22035
+ Addedthrough2@^0.5.1
+ Addedcore-util-is@1.0.3(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedreadable-stream@1.0.34(transitive)
+ Addedstring_decoder@0.10.31(transitive)
+ Addedthrough2@0.5.1(transitive)
+ Addedxtend@3.0.0(transitive)
- Removedmap-stream@^0.1.0
- Removedthrough@^2.3.4
- Removedmap-stream@0.1.0(transitive)
- Removedthrough@2.3.8(transitive)