New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

match-file

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

match-file - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

README.md

43

index.js

@@ -10,10 +10,11 @@ /*!

var mm = require('micromatch');
var path = require('path');
module.exports = function matchFile(name, file) {
function matchFile(name, file) {
if (typeof name !== 'string') {
throw new TypeError('expected a string');
throw new TypeError('expected name to be a string');
}
if (!isObject(file)) {
throw new TypeError('expected an object');
throw new TypeError('expected file to be an object');
}

@@ -27,6 +28,42 @@

|| (path.resolve(file.path) === path.resolve(name));
}
matchFile.matcher = function(pattern, options) {
if (typeof pattern !== 'string' && !Array.isArray(pattern)) {
throw new TypeError('expected pattern to be a string or array');
}
var isMatch = mm.matcher(pattern, options);
return function(file) {
if (typeof file === 'string') {
return isMatch(file);
}
return (pattern === file.key)
|| (pattern === file.path)
|| (pattern === file.relative)
|| (pattern === file.basename)
|| (pattern === file.stem)
|| (path.resolve(file.path) === path.resolve(pattern))
|| isMatch(file.key)
|| isMatch(file.path)
|| isMatch(file.relative)
|| isMatch(file.basename)
|| isMatch(file.stem)
|| isMatch(path.resolve(file.path));
};
};
matchFile.isMatch = function(patterns, file, options) {
return matchFile.matcher(patterns, options)(file);
};
function isObject(val) {
return val && typeof val === 'object';
}
/**
* Expose `matchFile`
*/
module.exports = matchFile;

42

package.json
{
"name": "match-file",
"description": "Returns true when the given `name` matches any of the path properties on a vinyl file",
"version": "0.1.0",
"description": "Returns true when the given `name` matches any of the path properties on a vinyl file.",
"version": "0.2.0",
"homepage": "https://github.com/jonschlinkert/match-file",

@@ -22,6 +22,14 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

},
"dependencies": {},
"dependencies": {
"micromatch": "^2.3.8"
},
"devDependencies": {
"gulp-format-md": "^0.1.5",
"mocha": "^2.3.4",
"gulp": "^3.9.1",
"gulp-eslint": "^2.0.0",
"gulp-format-md": "^0.1.9",
"gulp-istanbul": "^0.10.4",
"gulp-mocha": "^2.2.0",
"lazy-cache": "^1.0.4",
"mocha": "^2.4.5",
"through2": "^2.0.1",
"vinyl": "^1.1.1"

@@ -40,3 +48,2 @@ },

"verb": {
"layout": "default",
"plugins": [

@@ -48,9 +55,22 @@ "gulp-format-md"

"assemble",
"verb",
"templates",
"gulp",
"vinyl"
"generate",
"get-view",
"micromatch",
"verb"
]
}
},
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"lint": {
"reflinks": true
},
"reflinks": [
"micromatch",
"gulp",
"verb"
]
}
}
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