braces
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -75,2 +75,6 @@ 'use strict'; | ||
if (node.optimize === false) { | ||
options = utils.extend({}, options, {optimize: false}); | ||
} | ||
if (node.multiplier > 1) { | ||
@@ -77,0 +81,0 @@ node.parent.count *= node.multiplier; |
@@ -142,2 +142,3 @@ 'use strict'; | ||
.set('brace.open', function() { | ||
var parsed = this.parsed; | ||
var pos = this.position(); | ||
@@ -148,2 +149,11 @@ var m = this.match(/^\{(?!(?:[^\\}]?|,+)\})/); | ||
var prev = this.prev(); | ||
var last = utils.last(prev.nodes); | ||
// if the last parsed character was an extglob character | ||
// we need to _not optimize_ the brace pattern because | ||
// it might be mistaken for an extglob by a downstream parser | ||
if (last && last.val && isExtglobChar(last.val.slice(-1))) { | ||
last.optimize = false; | ||
} | ||
var open = pos(new Node({ | ||
@@ -201,2 +211,16 @@ type: 'brace.open', | ||
/** | ||
* Capture boundary characters | ||
*/ | ||
.set('boundary', function() { | ||
var pos = this.position(); | ||
var m = this.match(/^[$^](?!\{)/); | ||
if (!m) return; | ||
return pos(new Node({ | ||
type: 'text', | ||
val: m[0] | ||
})); | ||
}) | ||
/** | ||
* One or zero, non-comma characters wrapped in braces | ||
@@ -239,2 +263,10 @@ */ | ||
/** | ||
* Returns true if the character is an extglob character. | ||
*/ | ||
function isExtglobChar(ch) { | ||
return ch === '!' || ch === '@'|| ch === '*'|| ch === '?'|| ch === '+'; | ||
} | ||
/** | ||
* Combine text nodes, and calculate empty sets (`{,,}`) | ||
@@ -241,0 +273,0 @@ * @param {Function} `pos` Function to calculate node position |
@@ -223,2 +223,7 @@ 'use strict'; | ||
return function(tok) { | ||
if (tok.escaped && tok.val === 'b') { | ||
tok.val = '\\b'; | ||
return; | ||
} | ||
if (tok.val !== '(' && tok.val !== '[') return; | ||
@@ -330,3 +335,3 @@ var opts = utils.extend({}, options); | ||
utils.escapeRegex = function(str) { | ||
return str.replace(/\\?([!$^*?()\[\]{}+?/])/g, '\\$1'); | ||
return str.replace(/\\?([!^*?()\[\]{}+?/])/g, '\\$1'); | ||
}; |
{ | ||
"name": "braces", | ||
"description": "Bash-like brace expansion, implemented in JavaScript. Safer than other brace expansion libs, with complete support for the Bash 4.3 braces specification, without sacrificing speed.", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"homepage": "https://github.com/micromatch/braces", | ||
@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", |
57705
1124