minimatch 0.2.13 → 1.0.0
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.
- package/.travis.yml +4 -0
- package/README.md +2 -2
- package/minimatch.js +24 -5
- package/package.json +1 -1
- package/test/brace-expand.js +7 -0
- package/test/defaults.js +1 -1
- package/test/extglob-ending-with-state-char.js +1 -0
package/.travis.yml
ADDED
package/README.md
CHANGED
|
@@ -157,8 +157,8 @@ Perform a case-insensitive match.
|
|
|
157
157
|
### nonull
|
|
158
158
|
|
|
159
159
|
When a match is not found by `minimatch.match`, return a list containing
|
|
160
|
-
the pattern itself. When set, an empty list
|
|
161
|
-
no matches.
|
|
160
|
+
the pattern itself if this option is set. When not set, an empty list
|
|
161
|
+
is returned if there are no matches.
|
|
162
162
|
|
|
163
163
|
### matchBase
|
|
164
164
|
|
package/minimatch.js
CHANGED
|
@@ -260,6 +260,13 @@ minimatch.braceExpand = function (pattern, options) {
|
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
Minimatch.prototype.braceExpand = braceExpand
|
|
263
|
+
|
|
264
|
+
function pad(n, width, z) {
|
|
265
|
+
z = z || '0';
|
|
266
|
+
n = n + '';
|
|
267
|
+
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
|
|
268
|
+
}
|
|
269
|
+
|
|
263
270
|
function braceExpand (pattern, options) {
|
|
264
271
|
options = options || this.options
|
|
265
272
|
pattern = typeof pattern === "undefined"
|
|
@@ -332,13 +339,18 @@ function braceExpand (pattern, options) {
|
|
|
332
339
|
this.debug("numset", numset[1], numset[2])
|
|
333
340
|
var suf = braceExpand.call(this, pattern.substr(numset[0].length), options)
|
|
334
341
|
, start = +numset[1]
|
|
342
|
+
, needPadding = numset[1][0] === '0'
|
|
343
|
+
, startWidth = numset[1].length
|
|
344
|
+
, padded
|
|
335
345
|
, end = +numset[2]
|
|
336
346
|
, inc = start > end ? -1 : 1
|
|
337
347
|
, set = []
|
|
348
|
+
|
|
338
349
|
for (var i = start; i != (end + inc); i += inc) {
|
|
350
|
+
padded = needPadding ? pad(i, startWidth) : i + ''
|
|
339
351
|
// append all the suffixes
|
|
340
352
|
for (var ii = 0, ll = suf.length; ii < ll; ii ++) {
|
|
341
|
-
set.push(
|
|
353
|
+
set.push(padded + suf[ii])
|
|
342
354
|
}
|
|
343
355
|
}
|
|
344
356
|
return set
|
|
@@ -618,6 +630,7 @@ function parse (pattern, isSub) {
|
|
|
618
630
|
continue
|
|
619
631
|
}
|
|
620
632
|
|
|
633
|
+
clearStateChar()
|
|
621
634
|
re += "|"
|
|
622
635
|
continue
|
|
623
636
|
|
|
@@ -812,11 +825,12 @@ function makeRe () {
|
|
|
812
825
|
}
|
|
813
826
|
|
|
814
827
|
minimatch.match = function (list, pattern, options) {
|
|
828
|
+
options = options || {}
|
|
815
829
|
var mm = new Minimatch(pattern, options)
|
|
816
830
|
list = list.filter(function (f) {
|
|
817
831
|
return mm.match(f)
|
|
818
832
|
})
|
|
819
|
-
if (options.nonull && !list.length) {
|
|
833
|
+
if (mm.options.nonull && !list.length) {
|
|
820
834
|
list.push(pattern)
|
|
821
835
|
}
|
|
822
836
|
return list
|
|
@@ -852,12 +866,17 @@ function match (f, partial) {
|
|
|
852
866
|
var set = this.set
|
|
853
867
|
this.debug(this.pattern, "set", set)
|
|
854
868
|
|
|
855
|
-
|
|
869
|
+
// Find the basename of the path by looking for the last non-empty segment
|
|
870
|
+
var filename;
|
|
871
|
+
for (var i = f.length - 1; i >= 0; i--) {
|
|
872
|
+
filename = f[i]
|
|
873
|
+
if (filename) break
|
|
874
|
+
}
|
|
856
875
|
|
|
857
876
|
for (var i = 0, l = set.length; i < l; i ++) {
|
|
858
877
|
var pattern = set[i], file = f
|
|
859
878
|
if (options.matchBase && pattern.length === 1) {
|
|
860
|
-
file =
|
|
879
|
+
file = [filename]
|
|
861
880
|
}
|
|
862
881
|
var hit = this.matchOne(file, pattern, partial)
|
|
863
882
|
if (hit) {
|
|
@@ -974,7 +993,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
|
|
|
974
993
|
}
|
|
975
994
|
// no match was found.
|
|
976
995
|
// However, in partial mode, we can't say this is necessarily over.
|
|
977
|
-
// If there's more *pattern* left, then
|
|
996
|
+
// If there's more *pattern* left, then
|
|
978
997
|
if (partial) {
|
|
979
998
|
// ran out of file
|
|
980
999
|
this.debug("\n>>> no match, partial?", file, fr, pattern, pr)
|
package/package.json
CHANGED
package/test/brace-expand.js
CHANGED
|
@@ -21,6 +21,13 @@ tap.test("brace expansion", function (t) {
|
|
|
21
21
|
, "a4b"
|
|
22
22
|
, "a5b" ] ]
|
|
23
23
|
, [ "a{b}c", ["a{b}c"] ]
|
|
24
|
+
, [ "a{00..05}b"
|
|
25
|
+
, ["a00b"
|
|
26
|
+
,"a01b"
|
|
27
|
+
,"a02b"
|
|
28
|
+
,"a03b"
|
|
29
|
+
,"a04b"
|
|
30
|
+
,"a05b" ] ]
|
|
24
31
|
].forEach(function (tc) {
|
|
25
32
|
var p = tc[0]
|
|
26
33
|
, expect = tc[1]
|
package/test/defaults.js
CHANGED