Socket
Socket
Sign inDemoInstall

micromatch

Package Overview
Dependencies
94
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.1.0

4

index.js

@@ -193,2 +193,6 @@ /*!

function contains(fp, pattern, opts) {
if (typeof fp !== 'string') {
throw new TypeError(msg('contains', 'pattern', 'a string'));
}
opts = opts || {};

@@ -195,0 +199,0 @@ opts.contains = (pattern !== '');

73

lib/expand.js

@@ -30,5 +30,9 @@ /*!

function expand(pattern, options) {
var opts = options || {};
var glob = new Glob(pattern, opts);
if (typeof pattern !== 'string') {
throw new TypeError('micromatch.expand(): argument should be a string.');
}
var glob = new Glob(pattern, options || {});
var opts = glob.options;
function replace(re, str) {

@@ -39,3 +43,3 @@ glob.repl(re, esc(str));

// return early if the glob pattern tests `true`
// return early if glob pattern matches special patterns
if (specialCase(pattern) && opts.safemode) {

@@ -51,16 +55,10 @@ return new RegExp(utils.escapeRe(pattern), 'g');

// expand braces, e.g `{1..5}`
glob.track('before brackets');
glob.brackets();
glob.track('before braces');
glob.braces();
glob.track('after braces');
// parse the glob pattern into tokens
glob.parse();
glob.repl('[]', '\\[\\]');
glob.repl('(?', '__QMARK_GROUP__');
var tok = glob.tokens;
tok.is.negated = opts.negated;
// parse the glob pattern into tokens
var tok = glob.tokens;
if (tok.is.dotfile) {
glob.options.dot = true;
opts.dot = true;

@@ -77,2 +75,23 @@ }

// see if it might be a dotfile pattern
if (/[{,]\./.test(glob.pattern)) {
opts.makeRe = false;
opts.dot = true;
}
// expand braces, e.g `{1..5}`
glob.track('before brackets');
if (tok.is.brackets) {
glob.brackets();
}
glob.track('before braces');
if (tok.is.braces) {
glob.braces();
}
glob.track('after braces');
glob.repl('[]', '\\[\\]');
glob.repl('(?', '__QMARK_GROUP__');
// windows drives

@@ -82,3 +101,3 @@ replace(/^(\w):([\\\/]+?)/gi, lookahead + '$1:$2');

// negate slashes in exclusion ranges
if (/\[\^/.test(glob.pattern)) {
if (glob.pattern.indexOf('[^') !== -1) {
glob.pattern = negateSlash(glob.pattern);

@@ -105,4 +124,2 @@ }

glob.pattern = balance(glob.pattern, '[', ']');
// use heuristics to replace common escape patterns
glob.escape(glob.pattern);

@@ -112,3 +129,4 @@

// simplify the parsing and generated regex
if (tok.path.dirname === '') {
if (tok.path.dirname === '' && !tok.is.globstar) {
glob.track('before expand filename');
return expandFilename(glob, opts);

@@ -134,5 +152,5 @@ }

// ends with /*
replace(/\/\*$/g, '\\/' + stardot(opts));
replace(/\/\*$/, '\\/' + stardot(opts));
// ends with *, no slashes
replace(/(?!\/)\*$/g, boxQ);
replace(/(?!\/)\*$/, boxQ);
// has '*'

@@ -155,3 +173,3 @@ replace('*', stardot(opts));

// fix '[^\\\\/]'
glob.repl(/\[\^[\\/]+\]/g, box);
glob.repl(/\[\^[\\\/]+\]/g, box);
// '///' => '\/'

@@ -199,7 +217,7 @@ glob.repl(/\/+/g, '\\/');

default:
if (tok.path.basename === '*') {
glob.pattern = star(opts.dot) + '\\' + tok.path.extname;
if (tok.path.filename === '*' && !tok.path.dirname) {
glob.pattern = star(opts.dot) + '\\' + glob.pattern.slice(1);
} else {
glob.repl(/(?!\()\?/g, '[^/]');
if (tok.path.filename.charAt(0) !== '.') {
if (tok.path.basename.charAt(0) !== '.') {
opts.dot = true;

@@ -211,2 +229,6 @@ }

if (glob.pattern.charAt(0) === '.') {
glob.pattern = '\\' + glob.pattern;
}
glob.repl('__QMARK_GROUP__', '(?');

@@ -245,7 +267,5 @@ glob.unescape(glob.pattern);

var len = res.length;
var isFirst = res[0] === '';
var isLast = res[res.length - 1] === '';
res = res.filter(Boolean);
if (isFirst) {

@@ -281,3 +301,2 @@ res.unshift('');

glob = '(?:' + tmp + '|' + glob + ')';
// leading globstars

@@ -309,3 +328,3 @@ } else if (/^\*\*\/\w/.test(glob)) {

return '[^' + inner + ']';
})
});
}

@@ -312,0 +331,0 @@

'use strict';
var brackets = require('expand-brackets');
var extglob = require('extglob');
var braces = require('braces');

@@ -23,2 +22,6 @@ var parse = require('parse-glob');

/**
* Initialize defaults
*/
Glob.prototype.init = function(pattern) {

@@ -127,25 +130,2 @@ this.orig = pattern;

/**
* Return true if the glob pattern has an extglob
* pattern.
*
* @param {String} `pattern`
* @return {Boolean}
*/
Glob.prototype.hasExtglob = function(pattern) {
var re = /[@?!+*]\(/;
return this.has((pattern || this.pattern), re);
};
/**
* Expand extended globs in `glob.pattern`
*/
Glob.prototype.extglob = function() {
if (this.hasExtglob() && this.options.noextglob !== true) {
this.pattern = extglob(this.pattern);
}
};
/**
* Parse the given glob `pattern` or `glob.pattern`

@@ -170,4 +150,8 @@ */

Glob.prototype.repl = function(a, b) {
this.track('before repl: ');
Glob.prototype.repl = function(a, b, c) {
if (c) {
this.track('before ' + c);
} else {
this.track('before');
}
if (a && b && typeof a === 'string') {

@@ -180,3 +164,7 @@ this.pattern = this.pattern.split(a).join(b);

}
this.track('after repl: ');
if (c) {
this.track('after ' + c);
} else {
this.track('after');
}
};

@@ -183,0 +171,0 @@

{
"name": "micromatch",
"description": "Glob matching for javascript/node.js. A faster alternative to minimatch (10-45x faster on avg), with all the features you're used to using in your Grunt and gulp tasks.",
"version": "2.0.0",
"description": "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch (10-45x faster on avg). Just use `minimatch.isMatch()` instead of `multimatch()` or `minimatch()`.",
"version": "2.1.0",
"homepage": "https://github.com/jonschlinkert/micromatch",

@@ -38,3 +38,2 @@ "author": {

"expand-brackets": "^0.1.1",
"extglob": "^0.2.0",
"filename-regex": "^2.0.0",

@@ -44,3 +43,3 @@ "is-glob": "^1.1.1",

"object.omit": "^0.2.1",
"parse-glob": "^2.1.1",
"parse-glob": "^3.0.0",
"regex-cache": "^0.3.0"

@@ -47,0 +46,0 @@ },

# micromatch [![NPM version](https://badge.fury.io/js/micromatch.svg)](http://badge.fury.io/js/micromatch) [![Build Status](https://travis-ci.org/jonschlinkert/micromatch.svg)](https://travis-ci.org/jonschlinkert/micromatch)
> Glob matching for javascript/node.js. A faster alternative to minimatch (10-45x faster on avg), with all the features you're used to using in your Grunt and gulp tasks.
> Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch (10-45x faster on avg). Just use `minimatch.isMatch()` instead of `multimatch()` or `minimatch()`.

@@ -402,3 +402,3 @@ ## Features

As of March 06, 2015:
As of March 08, 2015:

@@ -493,3 +493,3 @@ ```bash

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 06, 2015._
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 08, 2015._

@@ -496,0 +496,0 @@ [switch]: #switch-from-minimatch

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc