minimatch 0.3.0 → 0.4.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/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
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.3.0",
5
+ "version": "0.4.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]