Comparing version 1.0.1 to 1.0.2
@@ -11,3 +11,3 @@ var util = require('utils-extend'); | ||
*/ | ||
function fileMatch(filter) { | ||
function fileMatch(filter, ignore) { | ||
if (filter === null) { | ||
@@ -29,2 +29,3 @@ return function() { | ||
var negate = []; | ||
var isIgnore = ignore ? 'i' : ''; | ||
@@ -65,4 +66,4 @@ filter.forEach(function(item) { | ||
match = match.length ? new RegExp(match.join('|')) : null; | ||
negate = negate.length ? new RegExp(negate.join('|')) : null; | ||
match = match.length ? new RegExp(match.join('|'), isIgnore) : null; | ||
negate = negate.length ? new RegExp(negate.join('|'), isIgnore) : null; | ||
@@ -69,0 +70,0 @@ return function(filepath) { |
{ | ||
"name": "file-match", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Match filepath is validated, or exclude filepath that don't need.", | ||
@@ -5,0 +5,0 @@ "main": "file-match.js", |
@@ -25,5 +25,25 @@ file-match | ||
filter('img/path/demo.png') // false | ||
var filter = fileMatch([ | ||
'path/*.js' | ||
], true); | ||
``` | ||
If the filter value is empty string or empty arry, it will always return false, | ||
if it's ``null``, will always return true. | ||
if it's ``null``, will always return true. | ||
#### filter description | ||
* `*.js` only match js files in current dir. | ||
* `**/*.js` match all js files. | ||
* `path/*.js` match js files in path. | ||
* `!*.js` exclude js files in current dir. | ||
* ``.{jpg,png,gif}`` means jpg, png or gif | ||
``` | ||
'**/*' // Match all files | ||
'!**/*.js' // Exclude all js files | ||
'**/*.{jpg,png,gif}' // Match jpg, png, or gif files | ||
``` | ||
### ignore case | ||
* ignore {boolean} [ignore = false] |
@@ -68,3 +68,16 @@ var assert = require('assert'); | ||
}); | ||
it('Ignore case', function() { | ||
var filter = fileMatch([ | ||
'path/demo.js' | ||
]); | ||
var filter2 = fileMatch([ | ||
'path/demo.js' | ||
], true); | ||
assert.equal(false, filter('path/DEMO.js')); | ||
assert.equal(true, filter2('path/DEMO.js')); | ||
}); | ||
}); | ||
}); |
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
6107
143
48