micromatch 4.0.6 → 4.0.7

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.

Files changed (3) hide show
  1. package/LICENSE +0 -0
  2. package/index.js +40 -51
  3. package/package.json +9 -27
package/LICENSE CHANGED
File without changes
package/index.js CHANGED
@@ -4,13 +4,7 @@ const util = require('util');
4
4
  const braces = require('braces');
5
5
  const picomatch = require('picomatch');
6
6
  const utils = require('picomatch/lib/utils');
7
-
8
- const isEmptyString = v => v === '' || v === './';
9
- const isObject = v => v !== null && typeof v === 'object' && !Array.isArray(v);
10
- const hasBraces = v => {
11
- const index = v.indexOf('{');
12
- return index > -1 && v.indexOf('}', index) > -1;
13
- };
7
+ const isEmptyString = val => val === '' || val === './';
14
8
 
15
9
  /**
16
10
  * Returns an array of strings that match one or more glob patterns.
@@ -34,12 +28,12 @@ const micromatch = (list, patterns, options) => {
34
28
  patterns = [].concat(patterns);
35
29
  list = [].concat(list);
36
30
 
37
- const omit = new Set();
38
- const keep = new Set();
39
- const items = new Set();
31
+ let omit = new Set();
32
+ let keep = new Set();
33
+ let items = new Set();
40
34
  let negatives = 0;
41
35
 
42
- const onResult = state => {
36
+ let onResult = state => {
43
37
  items.add(state.output);
44
38
  if (options && options.onResult) {
45
39
  options.onResult(state);
@@ -47,14 +41,14 @@ const micromatch = (list, patterns, options) => {
47
41
  };
48
42
 
49
43
  for (let i = 0; i < patterns.length; i++) {
50
- const isMatch = picomatch(String(patterns[i]), { windows: true, ...options, onResult }, true);
51
- const negated = isMatch.state.negated || isMatch.state.negatedExtglob;
44
+ let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true);
45
+ let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
52
46
  if (negated) negatives++;
53
47
 
54
- for (const item of list) {
55
- const matched = isMatch(item, true);
48
+ for (let item of list) {
49
+ let matched = isMatch(item, true);
56
50
 
57
- const match = negated ? !matched.isMatch : matched.isMatch;
51
+ let match = negated ? !matched.isMatch : matched.isMatch;
58
52
  if (!match) continue;
59
53
 
60
54
  if (negated) {
@@ -66,8 +60,8 @@ const micromatch = (list, patterns, options) => {
66
60
  }
67
61
  }
68
62
 
69
- const result = negatives === patterns.length ? [...items] : [...keep];
70
- const matches = result.filter(item => !omit.has(item));
63
+ let result = negatives === patterns.length ? [...items] : [...keep];
64
+ let matches = result.filter(item => !omit.has(item));
71
65
 
72
66
  if (options && matches.length === 0) {
73
67
  if (options.failglob === true) {
@@ -100,17 +94,14 @@ micromatch.match = micromatch;
100
94
  * const isMatch = mm.matcher('*.!(*a)');
101
95
  * console.log(isMatch('a.a')); //=> false
102
96
  * console.log(isMatch('a.b')); //=> true
103
- *
104
- * const isMatch = mm.matcher(['b.*', '*.a']);
105
- * console.log(isMatch('a.a')); //=> true
106
97
  * ```
107
- * @param {String|Array} `pattern` One or more glob patterns to use for matching.
98
+ * @param {String} `pattern` Glob pattern
108
99
  * @param {Object} `options`
109
100
  * @return {Function} Returns a matcher function.
110
101
  * @api public
111
102
  */
112
103
 
113
- micromatch.matcher = (pattern, options) => picomatch(pattern, { windows: true, ...options });
104
+ micromatch.matcher = (pattern, options) => picomatch(pattern, options);
114
105
 
115
106
  /**
116
107
  * Returns true if **any** of the given glob `patterns` match the specified `string`.
@@ -156,17 +147,17 @@ micromatch.any = micromatch.isMatch;
156
147
 
157
148
  micromatch.not = (list, patterns, options = {}) => {
158
149
  patterns = [].concat(patterns).map(String);
159
- const result = new Set();
160
- const items = [];
150
+ let result = new Set();
151
+ let items = [];
161
152
 
162
- const onResult = state => {
153
+ let onResult = state => {
163
154
  if (options.onResult) options.onResult(state);
164
155
  items.push(state.output);
165
156
  };
166
157
 
167
- const matches = new Set(micromatch(list, patterns, { ...options, onResult }));
158
+ let matches = new Set(micromatch(list, patterns, { ...options, onResult }));
168
159
 
169
- for (const item of items) {
160
+ for (let item of items) {
170
161
  if (!matches.has(item)) {
171
162
  result.add(item);
172
163
  }
@@ -237,12 +228,12 @@ micromatch.contains = (str, pattern, options) => {
237
228
  */
238
229
 
239
230
  micromatch.matchKeys = (obj, patterns, options) => {
240
- if (!isObject(obj)) {
231
+ if (!utils.isObject(obj)) {
241
232
  throw new TypeError('Expected the first argument to be an object');
242
233
  }
243
- const keys = micromatch(Object.keys(obj), patterns, options);
244
- const res = {};
245
- for (const key of keys) res[key] = obj[key];
234
+ let keys = micromatch(Object.keys(obj), patterns, options);
235
+ let res = {};
236
+ for (let key of keys) res[key] = obj[key];
246
237
  return res;
247
238
  };
248
239
 
@@ -266,10 +257,10 @@ micromatch.matchKeys = (obj, patterns, options) => {
266
257
  */
267
258
 
268
259
  micromatch.some = (list, patterns, options) => {
269
- const items = [].concat(list);
260
+ let items = [].concat(list);
270
261
 
271
- for (const pattern of [].concat(patterns)) {
272
- const isMatch = picomatch(String(pattern), { windows: true, ...options });
262
+ for (let pattern of [].concat(patterns)) {
263
+ let isMatch = picomatch(String(pattern), options);
273
264
  if (items.some(item => isMatch(item))) {
274
265
  return true;
275
266
  }
@@ -302,10 +293,10 @@ micromatch.some = (list, patterns, options) => {
302
293
  */
303
294
 
304
295
  micromatch.every = (list, patterns, options) => {
305
- const items = [].concat(list);
296
+ let items = [].concat(list);
306
297
 
307
- for (const pattern of [].concat(patterns)) {
308
- const isMatch = picomatch(String(pattern), { windows: true, ...options });
298
+ for (let pattern of [].concat(patterns)) {
299
+ let isMatch = picomatch(String(pattern), options);
309
300
  if (!items.every(item => isMatch(item))) {
310
301
  return false;
311
302
  }
@@ -345,7 +336,7 @@ micromatch.all = (str, patterns, options) => {
345
336
  throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
346
337
  }
347
338
 
348
- return [].concat(patterns).every(p => picomatch(p, { windows: true, ...options })(str));
339
+ return [].concat(patterns).every(p => picomatch(p, options)(str));
349
340
  };
350
341
 
351
342
  /**
@@ -368,9 +359,9 @@ micromatch.all = (str, patterns, options) => {
368
359
  */
369
360
 
370
361
  micromatch.capture = (glob, input, options) => {
371
- const windows = utils.isWindows(options);
372
- const regex = picomatch.makeRe(String(glob), { windows: true, ...options, capture: true });
373
- const match = regex.exec(windows ? utils.toPosixSlashes(input) : input);
362
+ let posix = utils.isWindows(options);
363
+ let regex = picomatch.makeRe(String(glob), { ...options, capture: true });
364
+ let match = regex.exec(posix ? utils.toPosixSlashes(input) : input);
374
365
 
375
366
  if (match) {
376
367
  return match.slice(1).map(v => v === void 0 ? '' : v);
@@ -393,7 +384,7 @@ micromatch.capture = (glob, input, options) => {
393
384
  * @api public
394
385
  */
395
386
 
396
- micromatch.makeRe = (pattern, options) => picomatch.makeRe(pattern, { windows: true, ...options });
387
+ micromatch.makeRe = (...args) => picomatch.makeRe(...args);
397
388
 
398
389
  /**
399
390
  * Scan a glob pattern to separate the pattern into segments. Used
@@ -409,7 +400,7 @@ micromatch.makeRe = (pattern, options) => picomatch.makeRe(pattern, { windows: t
409
400
  * @api public
410
401
  */
411
402
 
412
- micromatch.scan = (pattern, options) => picomatch.scan(pattern, { windows: true, ...options });
403
+ micromatch.scan = (...args) => picomatch.scan(...args);
413
404
 
414
405
  /**
415
406
  * Parse a glob pattern to create the source string for a regular
@@ -426,10 +417,10 @@ micromatch.scan = (pattern, options) => picomatch.scan(pattern, { windows: true,
426
417
  */
427
418
 
428
419
  micromatch.parse = (patterns, options) => {
429
- const res = [];
430
- for (const pattern of [].concat(patterns || [])) {
431
- for (const str of braces(String(pattern), options)) {
432
- res.push(picomatch.parse(str, { windows: utils.isWindows(), ...options }));
420
+ let res = [];
421
+ for (let pattern of [].concat(patterns || [])) {
422
+ for (let str of braces(String(pattern), options)) {
423
+ res.push(picomatch.parse(str, options));
433
424
  }
434
425
  }
435
426
  return res;
@@ -454,7 +445,7 @@ micromatch.parse = (patterns, options) => {
454
445
 
455
446
  micromatch.braces = (pattern, options) => {
456
447
  if (typeof pattern !== 'string') throw new TypeError('Expected a string');
457
- if ((options && options.nobrace === true) || !hasBraces(pattern)) {
448
+ if ((options && options.nobrace === true) || !/\{.*\}/.test(pattern)) {
458
449
  return [pattern];
459
450
  }
460
451
  return braces(pattern, options);
@@ -473,6 +464,4 @@ micromatch.braceExpand = (pattern, options) => {
473
464
  * Expose micromatch
474
465
  */
475
466
 
476
- // exposed for tests
477
- micromatch.hasBraces = hasBraces;
478
467
  module.exports = micromatch;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "micromatch",
3
3
  "description": "Glob matching for javascript/node.js. A replacement and faster alternative to minimatch and multimatch.",
4
- "version": "4.0.6",
4
+ "version": "4.0.7",
5
5
  "homepage": "https://github.com/micromatch/micromatch",
6
6
  "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
7
7
  "contributors": [
@@ -26,9 +26,7 @@
26
26
  "url": "https://github.com/micromatch/micromatch/issues"
27
27
  },
28
28
  "license": "MIT",
29
- "files": [
30
- "index.js"
31
- ],
29
+ "files": ["index.js"],
32
30
  "main": "index.js",
33
31
  "engines": {
34
32
  "node": ">=8.6"
@@ -38,13 +36,13 @@
38
36
  },
39
37
  "dependencies": {
40
38
  "braces": "^3.0.3",
41
- "picomatch": "^4.0.2"
39
+ "picomatch": "^2.3.1"
42
40
  },
43
41
  "devDependencies": {
44
42
  "fill-range": "^7.0.1",
45
43
  "gulp-format-md": "^2.0.0",
46
- "minimatch": "^9.0.3",
47
- "mocha": "^10.4.0",
44
+ "minimatch": "^5.0.1",
45
+ "mocha": "^9.2.2",
48
46
  "time-require": "github:jonschlinkert/time-require"
49
47
  },
50
48
  "keywords": [
@@ -90,30 +88,14 @@
90
88
  "verb": {
91
89
  "toc": "collapsible",
92
90
  "layout": "default",
93
- "tasks": [
94
- "readme"
95
- ],
96
- "plugins": [
97
- "gulp-format-md"
98
- ],
91
+ "tasks": ["readme"],
92
+ "plugins": ["gulp-format-md"],
99
93
  "lint": {
100
94
  "reflinks": true
101
95
  },
102
96
  "related": {
103
- "list": [
104
- "braces",
105
- "expand-brackets",
106
- "extglob",
107
- "fill-range",
108
- "nanomatch"
109
- ]
97
+ "list": ["braces", "expand-brackets", "extglob", "fill-range", "nanomatch"]
110
98
  },
111
- "reflinks": [
112
- "extglob",
113
- "fill-range",
114
- "glob-object",
115
- "minimatch",
116
- "multimatch"
117
- ]
99
+ "reflinks": ["extglob", "fill-range", "glob-object", "minimatch", "multimatch"]
118
100
  }
119
101
  }