micromatch 3.1.9 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of micromatch might be problematic. Click here for more details.
- package/CHANGELOG.md +86 -15
- package/LICENSE +1 -1
- package/README.md +409 -559
- package/index.js +238 -648
- package/package.json +28 -57
- package/lib/.DS_Store +0 -0
- package/lib/cache.js +0 -1
- package/lib/compilers.js +0 -77
- package/lib/parsers.js +0 -83
- package/lib/utils.js +0 -309
package/package.json
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "micromatch",
|
3
|
-
"description": "Glob matching for javascript/node.js. A
|
4
|
-
"version": "
|
3
|
+
"description": "Glob matching for javascript/node.js. A replacement and faster alternative to minimatch and multimatch.",
|
4
|
+
"version": "4.0.2",
|
5
5
|
"homepage": "https://github.com/micromatch/micromatch",
|
6
6
|
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
7
7
|
"contributors": [
|
8
|
+
"(https://github.com/DianeLooney)",
|
8
9
|
"Amila Welihinda (amilajack.com)",
|
9
10
|
"Bogdan Chadkin (https://github.com/TrySound)",
|
10
11
|
"Brian Woodward (https://twitter.com/doowb)",
|
@@ -17,7 +18,7 @@
|
|
17
18
|
"Paul Miller (paulmillr.com)",
|
18
19
|
"Tom Byrer (https://github.com/tomByrer)",
|
19
20
|
"Tyler Akins (http://rumkin.com)",
|
20
|
-
"(https://github.com/
|
21
|
+
"Peter Bright <drpizza@quiscalusmexicanus.org> (https://github.com/drpizza)"
|
21
22
|
],
|
22
23
|
"repository": "micromatch/micromatch",
|
23
24
|
"bugs": {
|
@@ -25,50 +26,35 @@
|
|
25
26
|
},
|
26
27
|
"license": "MIT",
|
27
28
|
"files": [
|
28
|
-
"index.js"
|
29
|
-
"lib"
|
29
|
+
"index.js"
|
30
30
|
],
|
31
31
|
"main": "index.js",
|
32
32
|
"engines": {
|
33
|
-
"node": ">=
|
33
|
+
"node": ">=8"
|
34
34
|
},
|
35
35
|
"scripts": {
|
36
36
|
"test": "mocha"
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
|
-
"
|
40
|
-
"
|
41
|
-
"braces": "^2.3.1",
|
42
|
-
"define-property": "^2.0.2",
|
43
|
-
"extend-shallow": "^3.0.2",
|
44
|
-
"extglob": "^2.0.4",
|
45
|
-
"fragment-cache": "^0.2.1",
|
46
|
-
"kind-of": "^6.0.2",
|
47
|
-
"nanomatch": "^1.2.9",
|
48
|
-
"object.pick": "^1.3.0",
|
49
|
-
"regex-not": "^1.0.0",
|
50
|
-
"snapdragon": "^0.8.1",
|
51
|
-
"to-regex": "^3.0.1"
|
39
|
+
"braces": "^3.0.1",
|
40
|
+
"picomatch": "^2.0.5"
|
52
41
|
},
|
53
42
|
"devDependencies": {
|
54
|
-
"
|
55
|
-
"
|
56
|
-
"gulp": "^3.9.1",
|
57
|
-
"gulp-format-md": "^1.0.0",
|
58
|
-
"gulp-istanbul": "^1.1.3",
|
59
|
-
"gulp-mocha": "^5.0.0",
|
60
|
-
"gulp-unused": "^0.2.1",
|
61
|
-
"is-windows": "^1.0.2",
|
43
|
+
"fill-range": "^7.0.1",
|
44
|
+
"gulp-format-md": "^2.0.0",
|
62
45
|
"minimatch": "^3.0.4",
|
63
|
-
"
|
64
|
-
"
|
65
|
-
"multimatch": "^2.1.0"
|
46
|
+
"mocha": "^5.2.0",
|
47
|
+
"time-require": "github:jonschlinkert/time-require"
|
66
48
|
},
|
67
49
|
"keywords": [
|
68
50
|
"bash",
|
51
|
+
"bracket",
|
52
|
+
"character-class",
|
69
53
|
"expand",
|
70
54
|
"expansion",
|
71
55
|
"expression",
|
56
|
+
"extglob",
|
57
|
+
"extglobs",
|
72
58
|
"file",
|
73
59
|
"files",
|
74
60
|
"filter",
|
@@ -77,6 +63,9 @@
|
|
77
63
|
"globbing",
|
78
64
|
"globs",
|
79
65
|
"globstar",
|
66
|
+
"lookahead",
|
67
|
+
"lookaround",
|
68
|
+
"lookbehind",
|
80
69
|
"match",
|
81
70
|
"matcher",
|
82
71
|
"matches",
|
@@ -84,33 +73,19 @@
|
|
84
73
|
"micromatch",
|
85
74
|
"minimatch",
|
86
75
|
"multimatch",
|
76
|
+
"negate",
|
77
|
+
"negation",
|
87
78
|
"path",
|
88
79
|
"pattern",
|
89
80
|
"patterns",
|
81
|
+
"posix",
|
90
82
|
"regex",
|
91
83
|
"regexp",
|
92
84
|
"regular",
|
93
85
|
"shell",
|
86
|
+
"star",
|
94
87
|
"wildcard"
|
95
88
|
],
|
96
|
-
"lintDeps": {
|
97
|
-
"dependencies": {
|
98
|
-
"options": {
|
99
|
-
"lock": {
|
100
|
-
"snapdragon": "^0.8.1"
|
101
|
-
}
|
102
|
-
}
|
103
|
-
},
|
104
|
-
"devDependencies": {
|
105
|
-
"files": {
|
106
|
-
"options": {
|
107
|
-
"ignore": [
|
108
|
-
"benchmark/**"
|
109
|
-
]
|
110
|
-
}
|
111
|
-
}
|
112
|
-
}
|
113
|
-
},
|
114
89
|
"verb": {
|
115
90
|
"toc": "collapsible",
|
116
91
|
"layout": "default",
|
@@ -120,9 +95,9 @@
|
|
120
95
|
"plugins": [
|
121
96
|
"gulp-format-md"
|
122
97
|
],
|
123
|
-
"
|
124
|
-
"
|
125
|
-
|
98
|
+
"lint": {
|
99
|
+
"reflinks": true
|
100
|
+
},
|
126
101
|
"related": {
|
127
102
|
"list": [
|
128
103
|
"braces",
|
@@ -132,16 +107,12 @@
|
|
132
107
|
"nanomatch"
|
133
108
|
]
|
134
109
|
},
|
135
|
-
"lint": {
|
136
|
-
"reflinks": true
|
137
|
-
},
|
138
110
|
"reflinks": [
|
139
|
-
"expand-brackets",
|
140
111
|
"extglob",
|
112
|
+
"fill-range",
|
141
113
|
"glob-object",
|
142
114
|
"minimatch",
|
143
|
-
"multimatch"
|
144
|
-
"snapdragon"
|
115
|
+
"multimatch"
|
145
116
|
]
|
146
117
|
}
|
147
118
|
}
|
package/lib/.DS_Store
DELETED
Binary file
|
package/lib/cache.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
module.exports = new (require('fragment-cache'))();
|
package/lib/compilers.js
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var nanomatch = require('nanomatch');
|
4
|
-
var extglob = require('extglob');
|
5
|
-
|
6
|
-
module.exports = function(snapdragon) {
|
7
|
-
var compilers = snapdragon.compiler.compilers;
|
8
|
-
var opts = snapdragon.options;
|
9
|
-
|
10
|
-
// register nanomatch compilers
|
11
|
-
snapdragon.use(nanomatch.compilers);
|
12
|
-
|
13
|
-
// get references to some specific nanomatch compilers before they
|
14
|
-
// are overridden by the extglob and/or custom compilers
|
15
|
-
var escape = compilers.escape;
|
16
|
-
var qmark = compilers.qmark;
|
17
|
-
var slash = compilers.slash;
|
18
|
-
var star = compilers.star;
|
19
|
-
var text = compilers.text;
|
20
|
-
var plus = compilers.plus;
|
21
|
-
var dot = compilers.dot;
|
22
|
-
|
23
|
-
// register extglob compilers or escape exglobs if disabled
|
24
|
-
if (opts.extglob === false || opts.noext === true) {
|
25
|
-
snapdragon.compiler.use(escapeExtglobs);
|
26
|
-
} else {
|
27
|
-
snapdragon.use(extglob.compilers);
|
28
|
-
}
|
29
|
-
|
30
|
-
snapdragon.use(function() {
|
31
|
-
this.options.star = this.options.star || function(/*node*/) {
|
32
|
-
return '[^\\\\/]*?';
|
33
|
-
};
|
34
|
-
});
|
35
|
-
|
36
|
-
// custom micromatch compilers
|
37
|
-
snapdragon.compiler
|
38
|
-
|
39
|
-
// reset referenced compiler
|
40
|
-
.set('dot', dot)
|
41
|
-
.set('escape', escape)
|
42
|
-
.set('plus', plus)
|
43
|
-
.set('slash', slash)
|
44
|
-
.set('qmark', qmark)
|
45
|
-
.set('star', star)
|
46
|
-
.set('text', text);
|
47
|
-
};
|
48
|
-
|
49
|
-
function escapeExtglobs(compiler) {
|
50
|
-
compiler.set('paren', function(node) {
|
51
|
-
var val = '';
|
52
|
-
visit(node, function(tok) {
|
53
|
-
if (tok.val) val += (/^\W/.test(tok.val) ? '\\' : '') + tok.val;
|
54
|
-
});
|
55
|
-
return this.emit(val, node);
|
56
|
-
});
|
57
|
-
|
58
|
-
/**
|
59
|
-
* Visit `node` with the given `fn`
|
60
|
-
*/
|
61
|
-
|
62
|
-
function visit(node, fn) {
|
63
|
-
return node.nodes ? mapVisit(node.nodes, fn) : fn(node);
|
64
|
-
}
|
65
|
-
|
66
|
-
/**
|
67
|
-
* Map visit over array of `nodes`.
|
68
|
-
*/
|
69
|
-
|
70
|
-
function mapVisit(nodes, fn) {
|
71
|
-
var len = nodes.length;
|
72
|
-
var idx = -1;
|
73
|
-
while (++idx < len) {
|
74
|
-
visit(nodes[idx], fn);
|
75
|
-
}
|
76
|
-
}
|
77
|
-
}
|
package/lib/parsers.js
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var extglob = require('extglob');
|
4
|
-
var nanomatch = require('nanomatch');
|
5
|
-
var regexNot = require('regex-not');
|
6
|
-
var toRegex = require('to-regex');
|
7
|
-
var not;
|
8
|
-
|
9
|
-
/**
|
10
|
-
* Characters to use in negation regex (we want to "not" match
|
11
|
-
* characters that are matched by other parsers)
|
12
|
-
*/
|
13
|
-
|
14
|
-
var TEXT = '([!@*?+]?\\(|\\)|\\[:?(?=.*?:?\\])|:?\\]|[*+?!^$.\\\\/])+';
|
15
|
-
var createNotRegex = function(opts) {
|
16
|
-
return not || (not = textRegex(TEXT));
|
17
|
-
};
|
18
|
-
|
19
|
-
/**
|
20
|
-
* Parsers
|
21
|
-
*/
|
22
|
-
|
23
|
-
module.exports = function(snapdragon) {
|
24
|
-
var parsers = snapdragon.parser.parsers;
|
25
|
-
|
26
|
-
// register nanomatch parsers
|
27
|
-
snapdragon.use(nanomatch.parsers);
|
28
|
-
|
29
|
-
// get references to some specific nanomatch parsers before they
|
30
|
-
// are overridden by the extglob and/or parsers
|
31
|
-
var escape = parsers.escape;
|
32
|
-
var slash = parsers.slash;
|
33
|
-
var qmark = parsers.qmark;
|
34
|
-
var plus = parsers.plus;
|
35
|
-
var star = parsers.star;
|
36
|
-
var dot = parsers.dot;
|
37
|
-
|
38
|
-
// register extglob parsers
|
39
|
-
snapdragon.use(extglob.parsers);
|
40
|
-
|
41
|
-
// custom micromatch parsers
|
42
|
-
snapdragon.parser
|
43
|
-
.use(function() {
|
44
|
-
// override "notRegex" created in nanomatch parser
|
45
|
-
this.notRegex = /^\!+(?!\()/;
|
46
|
-
})
|
47
|
-
// reset the referenced parsers
|
48
|
-
.capture('escape', escape)
|
49
|
-
.capture('slash', slash)
|
50
|
-
.capture('qmark', qmark)
|
51
|
-
.capture('star', star)
|
52
|
-
.capture('plus', plus)
|
53
|
-
.capture('dot', dot)
|
54
|
-
|
55
|
-
/**
|
56
|
-
* Override `text` parser
|
57
|
-
*/
|
58
|
-
|
59
|
-
.capture('text', function() {
|
60
|
-
if (this.isInside('bracket')) return;
|
61
|
-
var pos = this.position();
|
62
|
-
var m = this.match(createNotRegex(this.options));
|
63
|
-
if (!m || !m[0]) return;
|
64
|
-
|
65
|
-
// escape regex boundary characters and simple brackets
|
66
|
-
var val = m[0].replace(/([[\]^$])/g, '\\$1');
|
67
|
-
|
68
|
-
return pos({
|
69
|
-
type: 'text',
|
70
|
-
val: val
|
71
|
-
});
|
72
|
-
});
|
73
|
-
};
|
74
|
-
|
75
|
-
/**
|
76
|
-
* Create text regex
|
77
|
-
*/
|
78
|
-
|
79
|
-
function textRegex(pattern) {
|
80
|
-
var notStr = regexNot.create(pattern, {contains: true, strictClose: false});
|
81
|
-
var prefix = '(?:[\\^]|\\\\|';
|
82
|
-
return toRegex(prefix + notStr + ')', {strictClose: false});
|
83
|
-
}
|
package/lib/utils.js
DELETED
@@ -1,309 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var utils = module.exports;
|
4
|
-
var path = require('path');
|
5
|
-
|
6
|
-
/**
|
7
|
-
* Module dependencies
|
8
|
-
*/
|
9
|
-
|
10
|
-
var Snapdragon = require('snapdragon');
|
11
|
-
utils.define = require('define-property');
|
12
|
-
utils.diff = require('arr-diff');
|
13
|
-
utils.extend = require('extend-shallow');
|
14
|
-
utils.pick = require('object.pick');
|
15
|
-
utils.typeOf = require('kind-of');
|
16
|
-
utils.unique = require('array-unique');
|
17
|
-
|
18
|
-
/**
|
19
|
-
* Returns true if the platform is windows, or `path.sep` is `\\`.
|
20
|
-
* This is defined as a function to allow `path.sep` to be set in unit tests,
|
21
|
-
* or by the user, if there is a reason to do so.
|
22
|
-
* @return {Boolean}
|
23
|
-
*/
|
24
|
-
|
25
|
-
utils.isWindows = function() {
|
26
|
-
return path.sep === '\\' || process.platform === 'win32';
|
27
|
-
};
|
28
|
-
|
29
|
-
/**
|
30
|
-
* Get the `Snapdragon` instance to use
|
31
|
-
*/
|
32
|
-
|
33
|
-
utils.instantiate = function(ast, options) {
|
34
|
-
var snapdragon;
|
35
|
-
// if an instance was created by `.parse`, use that instance
|
36
|
-
if (utils.typeOf(ast) === 'object' && ast.snapdragon) {
|
37
|
-
snapdragon = ast.snapdragon;
|
38
|
-
// if the user supplies an instance on options, use that instance
|
39
|
-
} else if (utils.typeOf(options) === 'object' && options.snapdragon) {
|
40
|
-
snapdragon = options.snapdragon;
|
41
|
-
// create a new instance
|
42
|
-
} else {
|
43
|
-
snapdragon = new Snapdragon(options);
|
44
|
-
}
|
45
|
-
|
46
|
-
utils.define(snapdragon, 'parse', function(str, options) {
|
47
|
-
var parsed = Snapdragon.prototype.parse.apply(this, arguments);
|
48
|
-
parsed.input = str;
|
49
|
-
|
50
|
-
// escape unmatched brace/bracket/parens
|
51
|
-
var last = this.parser.stack.pop();
|
52
|
-
if (last && this.options.strictErrors !== true) {
|
53
|
-
var open = last.nodes[0];
|
54
|
-
var inner = last.nodes[1];
|
55
|
-
if (last.type === 'bracket') {
|
56
|
-
if (inner.val.charAt(0) === '[') {
|
57
|
-
inner.val = '\\' + inner.val;
|
58
|
-
}
|
59
|
-
|
60
|
-
} else {
|
61
|
-
open.val = '\\' + open.val;
|
62
|
-
var sibling = open.parent.nodes[1];
|
63
|
-
if (sibling.type === 'star') {
|
64
|
-
sibling.loose = true;
|
65
|
-
}
|
66
|
-
}
|
67
|
-
}
|
68
|
-
|
69
|
-
// add non-enumerable parser reference
|
70
|
-
utils.define(parsed, 'parser', this.parser);
|
71
|
-
return parsed;
|
72
|
-
});
|
73
|
-
|
74
|
-
return snapdragon;
|
75
|
-
};
|
76
|
-
|
77
|
-
/**
|
78
|
-
* Create the key to use for memoization. The key is generated
|
79
|
-
* by iterating over the options and concatenating key-value pairs
|
80
|
-
* to the pattern string.
|
81
|
-
*/
|
82
|
-
|
83
|
-
utils.createKey = function(pattern, options) {
|
84
|
-
if (utils.typeOf(options) !== 'object') {
|
85
|
-
return pattern;
|
86
|
-
}
|
87
|
-
var val = pattern;
|
88
|
-
var keys = Object.keys(options);
|
89
|
-
for (var i = 0; i < keys.length; i++) {
|
90
|
-
var key = keys[i];
|
91
|
-
val += ';' + key + '=' + String(options[key]);
|
92
|
-
}
|
93
|
-
return val;
|
94
|
-
};
|
95
|
-
|
96
|
-
/**
|
97
|
-
* Cast `val` to an array
|
98
|
-
* @return {Array}
|
99
|
-
*/
|
100
|
-
|
101
|
-
utils.arrayify = function(val) {
|
102
|
-
if (typeof val === 'string') return [val];
|
103
|
-
return val ? (Array.isArray(val) ? val : [val]) : [];
|
104
|
-
};
|
105
|
-
|
106
|
-
/**
|
107
|
-
* Return true if `val` is a non-empty string
|
108
|
-
*/
|
109
|
-
|
110
|
-
utils.isString = function(val) {
|
111
|
-
return typeof val === 'string';
|
112
|
-
};
|
113
|
-
|
114
|
-
/**
|
115
|
-
* Return true if `val` is a non-empty string
|
116
|
-
*/
|
117
|
-
|
118
|
-
utils.isObject = function(val) {
|
119
|
-
return utils.typeOf(val) === 'object';
|
120
|
-
};
|
121
|
-
|
122
|
-
/**
|
123
|
-
* Returns true if the given `str` has special characters
|
124
|
-
*/
|
125
|
-
|
126
|
-
utils.hasSpecialChars = function(str) {
|
127
|
-
return /(?:(?:(^|\/)[!.])|[*?+()|\[\]{}]|[+@]\()/.test(str);
|
128
|
-
};
|
129
|
-
|
130
|
-
/**
|
131
|
-
* Escape regex characters in the given string
|
132
|
-
*/
|
133
|
-
|
134
|
-
utils.escapeRegex = function(str) {
|
135
|
-
return str.replace(/[-[\]{}()^$|*+?.\\\/\s]/g, '\\$&');
|
136
|
-
};
|
137
|
-
|
138
|
-
/**
|
139
|
-
* Normalize slashes in the given filepath.
|
140
|
-
*
|
141
|
-
* @param {String} `filepath`
|
142
|
-
* @return {String}
|
143
|
-
*/
|
144
|
-
|
145
|
-
utils.toPosixPath = function(str) {
|
146
|
-
return str.replace(/\\+/g, '/');
|
147
|
-
};
|
148
|
-
|
149
|
-
/**
|
150
|
-
* Strip backslashes before special characters in a string.
|
151
|
-
*
|
152
|
-
* @param {String} `str`
|
153
|
-
* @return {String}
|
154
|
-
*/
|
155
|
-
|
156
|
-
utils.unescape = function(str) {
|
157
|
-
return utils.toPosixPath(str.replace(/\\(?=[*+?!.])/g, ''));
|
158
|
-
};
|
159
|
-
|
160
|
-
/**
|
161
|
-
* Strip the prefix from a filepath
|
162
|
-
* @param {String} `fp`
|
163
|
-
* @return {String}
|
164
|
-
*/
|
165
|
-
|
166
|
-
utils.stripPrefix = function(str) {
|
167
|
-
if (str.charAt(0) !== '.') {
|
168
|
-
return str;
|
169
|
-
}
|
170
|
-
var ch = str.charAt(1);
|
171
|
-
if (utils.isSlash(ch)) {
|
172
|
-
return str.slice(2);
|
173
|
-
}
|
174
|
-
return str;
|
175
|
-
};
|
176
|
-
|
177
|
-
/**
|
178
|
-
* Returns true if the given str is an escaped or
|
179
|
-
* unescaped path character
|
180
|
-
*/
|
181
|
-
|
182
|
-
utils.isSlash = function(str) {
|
183
|
-
return str === '/' || str === '\\/' || str === '\\' || str === '\\\\';
|
184
|
-
};
|
185
|
-
|
186
|
-
/**
|
187
|
-
* Returns a function that returns true if the given
|
188
|
-
* pattern matches or contains a `filepath`
|
189
|
-
*
|
190
|
-
* @param {String} `pattern`
|
191
|
-
* @return {Function}
|
192
|
-
*/
|
193
|
-
|
194
|
-
utils.matchPath = function(pattern, options) {
|
195
|
-
return (options && options.contains)
|
196
|
-
? utils.containsPattern(pattern, options)
|
197
|
-
: utils.equalsPattern(pattern, options);
|
198
|
-
};
|
199
|
-
|
200
|
-
/**
|
201
|
-
* Returns true if the given (original) filepath or unixified path are equal
|
202
|
-
* to the given pattern.
|
203
|
-
*/
|
204
|
-
|
205
|
-
utils._equals = function(filepath, unixPath, pattern) {
|
206
|
-
return pattern === filepath || pattern === unixPath;
|
207
|
-
};
|
208
|
-
|
209
|
-
/**
|
210
|
-
* Returns true if the given (original) filepath or unixified path contain
|
211
|
-
* the given pattern.
|
212
|
-
*/
|
213
|
-
|
214
|
-
utils._contains = function(filepath, unixPath, pattern) {
|
215
|
-
return filepath.indexOf(pattern) !== -1 || unixPath.indexOf(pattern) !== -1;
|
216
|
-
};
|
217
|
-
|
218
|
-
/**
|
219
|
-
* Returns a function that returns true if the given
|
220
|
-
* pattern is the same as a given `filepath`
|
221
|
-
*
|
222
|
-
* @param {String} `pattern`
|
223
|
-
* @return {Function}
|
224
|
-
*/
|
225
|
-
|
226
|
-
utils.equalsPattern = function(pattern, options) {
|
227
|
-
var unixify = utils.unixify(options);
|
228
|
-
options = options || {};
|
229
|
-
|
230
|
-
return function fn(filepath) {
|
231
|
-
var equal = utils._equals(filepath, unixify(filepath), pattern);
|
232
|
-
if (equal === true || options.nocase !== true) {
|
233
|
-
return equal;
|
234
|
-
}
|
235
|
-
var lower = filepath.toLowerCase();
|
236
|
-
return utils._equals(lower, unixify(lower), pattern);
|
237
|
-
};
|
238
|
-
};
|
239
|
-
|
240
|
-
/**
|
241
|
-
* Returns a function that returns true if the given
|
242
|
-
* pattern contains a `filepath`
|
243
|
-
*
|
244
|
-
* @param {String} `pattern`
|
245
|
-
* @return {Function}
|
246
|
-
*/
|
247
|
-
|
248
|
-
utils.containsPattern = function(pattern, options) {
|
249
|
-
var unixify = utils.unixify(options);
|
250
|
-
options = options || {};
|
251
|
-
|
252
|
-
return function(filepath) {
|
253
|
-
var contains = utils._contains(filepath, unixify(filepath), pattern);
|
254
|
-
if (contains === true || options.nocase !== true) {
|
255
|
-
return contains;
|
256
|
-
}
|
257
|
-
var lower = filepath.toLowerCase();
|
258
|
-
return utils._contains(lower, unixify(lower), pattern);
|
259
|
-
};
|
260
|
-
};
|
261
|
-
|
262
|
-
/**
|
263
|
-
* Returns a function that returns true if the given
|
264
|
-
* regex matches the `filename` of a file path.
|
265
|
-
*
|
266
|
-
* @param {RegExp} `re` Matching regex
|
267
|
-
* @return {Function}
|
268
|
-
*/
|
269
|
-
|
270
|
-
utils.matchBasename = function(re) {
|
271
|
-
return function(filepath) {
|
272
|
-
return re.test(path.basename(filepath));
|
273
|
-
};
|
274
|
-
};
|
275
|
-
|
276
|
-
/**
|
277
|
-
* Determines the filepath to return based on the provided options.
|
278
|
-
* @return {any}
|
279
|
-
*/
|
280
|
-
|
281
|
-
utils.value = function(str, unixify, options) {
|
282
|
-
if (options && options.unixify === false) {
|
283
|
-
return str;
|
284
|
-
}
|
285
|
-
return unixify(str);
|
286
|
-
};
|
287
|
-
|
288
|
-
/**
|
289
|
-
* Returns a function that normalizes slashes in a string to forward
|
290
|
-
* slashes, strips `./` from beginning of paths, and optionally unescapes
|
291
|
-
* special characters.
|
292
|
-
* @return {Function}
|
293
|
-
*/
|
294
|
-
|
295
|
-
utils.unixify = function(options) {
|
296
|
-
options = options || {};
|
297
|
-
return function(filepath) {
|
298
|
-
if (utils.isWindows() || options.unixify === true) {
|
299
|
-
filepath = utils.toPosixPath(filepath);
|
300
|
-
}
|
301
|
-
if (options.stripPrefix !== false) {
|
302
|
-
filepath = utils.stripPrefix(filepath);
|
303
|
-
}
|
304
|
-
if (options.unescape === true) {
|
305
|
-
filepath = utils.unescape(filepath);
|
306
|
-
}
|
307
|
-
return filepath;
|
308
|
-
};
|
309
|
-
};
|