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 ADDED
@@ -0,0 +1,4 @@
1
+ language: node_js
2
+ node_js:
3
+ - 0.10
4
+ - 0.11
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 is returned if there are
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(i + suf[ii])
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
- var splitFile = path.basename(f.join("/")).split("/")
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 = splitFile
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
@@ -2,7 +2,7 @@
2
2
  "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
3
3
  "name": "minimatch",
4
4
  "description": "a glob matcher in javascript",
5
- "version": "0.2.13",
5
+ "version": "1.0.0",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git://github.com/isaacs/minimatch.git"
@@ -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
@@ -237,7 +237,7 @@ tap.test("basic tests", function (t) {
237
237
 
238
238
  var pattern = c[0]
239
239
  , expect = c[1].sort(alpha)
240
- , options = c[2] || {}
240
+ , options = c[2]
241
241
  , f = c[3] || files
242
242
  , tapOpts = c[4] || {}
243
243
 
@@ -3,5 +3,6 @@ var minimatch = require('../')
3
3
 
4
4
  test('extglob ending with statechar', function(t) {
5
5
  t.notOk(minimatch('ax', 'a?(b*)'))
6
+ t.ok(minimatch('ax', '?(a*|b)'))
6
7
  t.end()
7
8
  })