aboutsummaryrefslogtreecommitdiff
path: root/node_modules/nanomatch/lib/parsers.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/nanomatch/lib/parsers.js')
-rw-r--r--node_modules/nanomatch/lib/parsers.js28
1 files changed, 15 insertions, 13 deletions
diff --git a/node_modules/nanomatch/lib/parsers.js b/node_modules/nanomatch/lib/parsers.js
index 0b0a59a59..f87df8f34 100644
--- a/node_modules/nanomatch/lib/parsers.js
+++ b/node_modules/nanomatch/lib/parsers.js
@@ -2,7 +2,6 @@
var regexNot = require('regex-not');
var toRegex = require('to-regex');
-var isOdd = require('is-odd');
/**
* Characters to use in negation regex (we want to "not" match
@@ -10,7 +9,7 @@ var isOdd = require('is-odd');
*/
var cached;
-var NOT_REGEX = '[!*+?$^"\'.\\\\/\\[]+';
+var NOT_REGEX = '[\\[!*+?$^"\'.\\\\/]+';
var not = createTextRegex(NOT_REGEX);
/**
@@ -33,12 +32,10 @@ module.exports = function(nanomatch, options) {
* Beginning-of-string
*/
- .capture('bos', function() {
+ .capture('prefix', function() {
if (this.parsed) return;
- var pos = this.position();
var m = this.match(/^\.[\\/]/);
if (!m) return;
-
this.state.strictOpen = !!this.options.strictOpen;
this.state.addPrefix = true;
})
@@ -92,11 +89,11 @@ module.exports = function(nanomatch, options) {
.capture('not', function() {
var parsed = this.parsed;
var pos = this.position();
- var m = this.match(this.notRegex || /^\!+/);
+ var m = this.match(this.notRegex || /^!+/);
if (!m) return;
var val = m[0];
- var isNegated = isOdd(val.length);
+ var isNegated = (val.length % 2) === 1;
if (parsed === '' && !isNegated) {
val = '';
}
@@ -167,16 +164,22 @@ module.exports = function(nanomatch, options) {
.capture('globstar', function() {
var parsed = this.parsed;
var pos = this.position();
- var m = this.match(/^\*{2}(?![*(])(?=[,\/)]|$)/);
+ var m = this.match(/^\*{2}(?![*(])(?=[,)/]|$)/);
if (!m) return;
var type = opts.noglobstar !== true ? 'globstar' : 'star';
var node = pos({type: type, parsed: parsed});
+ this.state.metachar = true;
- if (this.input.slice(0, 4) === '/**/') {
+ while (this.input.slice(0, 4) === '/**/') {
this.input = this.input.slice(3);
}
+ node.isInside = {
+ brace: this.isInside('brace'),
+ paren: this.isInside('paren')
+ };
+
if (type === 'globstar') {
this.state.globstar = true;
node.val = '**';
@@ -186,7 +189,6 @@ module.exports = function(nanomatch, options) {
node.val = '*';
}
- this.state.metachar = true;
return node;
})
@@ -196,7 +198,7 @@ module.exports = function(nanomatch, options) {
.capture('star', function() {
var pos = this.position();
- var starRe = /^(?:\*(?![*(])|[*]{3,}(?!\()|[*]{2}(?![(\/]|$)|\*(?=\*\())/;
+ var starRe = /^(?:\*(?![*(])|[*]{3,}(?!\()|[*]{2}(?![(/]|$)|\*(?=\*\())/;
var m = this.match(starRe);
if (!m) return;
@@ -269,7 +271,7 @@ module.exports = function(nanomatch, options) {
.capture('bracket', function() {
var pos = this.position();
- var m = this.match(/^(?:\[([!^]?)([^\]]+|\]\-)(\]|[^*+?]+)|\[)/);
+ var m = this.match(/^(?:\[([!^]?)([^\]]+|\]-)(\]|[^*+?]+)|\[)/);
if (!m) return;
var val = m[0];
@@ -373,7 +375,7 @@ function createTextRegex(pattern) {
if (cached) return cached;
var opts = {contains: true, strictClose: false};
var not = regexNot.create(pattern, opts);
- var re = toRegex('^(?:[*]\\(|' + not + ')', opts);
+ var re = toRegex('^(?:[*]\\((?=.)|' + not + ')', opts);
return (cached = re);
}