Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

file-match

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-match - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

7

file-match.js

@@ -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'));
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc