aboutsummaryrefslogtreecommitdiff
path: root/node_modules/anymatch/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/anymatch/index.js')
-rw-r--r--node_modules/anymatch/index.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/node_modules/anymatch/index.js b/node_modules/anymatch/index.js
index fd70ba07e..e41161850 100644
--- a/node_modules/anymatch/index.js
+++ b/node_modules/anymatch/index.js
@@ -1,8 +1,9 @@
'use strict';
-var arrify = require('arrify');
var micromatch = require('micromatch');
-var path = require('path');
+var normalize = require('normalize-path');
+var path = require('path'); // required for tests.
+var arrify = function(a) { return a == null ? [] : (Array.isArray(a) ? a : [a]); };
var anymatch = function(criteria, value, returnIndex, startIndex, endIndex) {
criteria = arrify(criteria);
@@ -15,12 +16,12 @@ var anymatch = function(criteria, value, returnIndex, startIndex, endIndex) {
}
startIndex = startIndex || 0;
var string = value[0];
- var altString;
+ var altString, altValue;
var matched = false;
var matchIndex = -1;
- function testCriteria (criterion, index) {
+ function testCriteria(criterion, index) {
var result;
- switch (toString.call(criterion)) {
+ switch (Object.prototype.toString.call(criterion)) {
case '[object String]':
result = string === criterion || altString && altString === criterion;
result = result || micromatch.isMatch(string, criterion);
@@ -30,6 +31,7 @@ var anymatch = function(criteria, value, returnIndex, startIndex, endIndex) {
break;
case '[object Function]':
result = criterion.apply(null, value);
+ result = result || altValue && criterion.apply(null, altValue);
break;
default:
result = false;
@@ -53,8 +55,9 @@ var anymatch = function(criteria, value, returnIndex, startIndex, endIndex) {
}, []);
if (!negGlobs.length || !micromatch.any(string, negGlobs)) {
if (path.sep === '\\' && typeof string === 'string') {
- altString = string.split('\\').join('/');
+ altString = normalize(string);
altString = altString === string ? null : altString;
+ if (altString) altValue = [altString].concat(value.slice(1));
}
matched = crit.slice(startIndex, endIndex).some(testCriteria);
}