aboutsummaryrefslogtreecommitdiff
path: root/node_modules/nanomatch/lib
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/nanomatch/lib
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
update packages
Diffstat (limited to 'node_modules/nanomatch/lib')
-rw-r--r--node_modules/nanomatch/lib/.DS_Storebin6148 -> 0 bytes
-rw-r--r--node_modules/nanomatch/lib/compilers.js70
-rw-r--r--node_modules/nanomatch/lib/parsers.js28
-rw-r--r--node_modules/nanomatch/lib/utils.js31
4 files changed, 78 insertions, 51 deletions
diff --git a/node_modules/nanomatch/lib/.DS_Store b/node_modules/nanomatch/lib/.DS_Store
deleted file mode 100644
index 5008ddfcf..000000000
--- a/node_modules/nanomatch/lib/.DS_Store
+++ /dev/null
Binary files differ
diff --git a/node_modules/nanomatch/lib/compilers.js b/node_modules/nanomatch/lib/compilers.js
index c2331b287..d7a786e7a 100644
--- a/node_modules/nanomatch/lib/compilers.js
+++ b/node_modules/nanomatch/lib/compilers.js
@@ -1,11 +1,29 @@
'use strict';
/**
- * Nanomatch compilers
- */
+* Nanomatch compilers
+*/
module.exports = function(nanomatch, options) {
- var star = '[^/]*?';
+ function slash() {
+ if (options && typeof options.slash === 'string') {
+ return options.slash;
+ }
+ if (options && typeof options.slash === 'function') {
+ return options.slash.call(nanomatch);
+ }
+ return '\\\\/';
+ }
+
+ function star() {
+ if (options && typeof options.star === 'string') {
+ return options.star;
+ }
+ if (options && typeof options.star === 'function') {
+ return options.star.call(nanomatch);
+ }
+ return '[^' + slash() + ']*?';
+ }
var ast = nanomatch.ast = nanomatch.parser.ast;
ast.state = nanomatch.parser.state;
@@ -15,6 +33,7 @@ module.exports = function(nanomatch, options) {
/**
* Negation / escaping
*/
+
.set('not', function(node) {
var prev = this.prev();
if (this.options.nonegate === true || prev.type !== 'bos') {
@@ -23,7 +42,7 @@ module.exports = function(nanomatch, options) {
return this.emit(node.val, node);
})
.set('escape', function(node) {
- if (this.options.unescape && /^[\w_.-]/.test(node.val)) {
+ if (this.options.unescape && /^[-\w_.]/.test(node.val)) {
return this.emit(node.val, node);
}
return this.emit('\\' + node.val, node);
@@ -60,7 +79,7 @@ module.exports = function(nanomatch, options) {
return this.emit(node.val, node);
})
.set('slash', function(node, nodes, i) {
- var val = '\\' + node.val;
+ var val = '[' + slash() + ']';
var parent = node.parent;
var prev = this.prev();
@@ -128,7 +147,7 @@ module.exports = function(nanomatch, options) {
*/
.set('square', function(node) {
- var val = !/^\w/.test(node.val) ? '\\' + node.val : node.val;
+ var val = (/^\W/.test(node.val) ? '\\' : '') + node.val;
return this.emit(val, node);
})
@@ -138,6 +157,8 @@ module.exports = function(nanomatch, options) {
.set('qmark', function(node) {
var prev = this.prev();
+ // don't use "slash" variable so that we always avoid
+ // matching backslashes and slashes with a qmark
var val = '[^.\\\\/]';
if (this.options.dot || (prev.type !== 'bos' && prev.type !== 'slash')) {
val = '[^\\\\/]';
@@ -184,18 +205,18 @@ module.exports = function(nanomatch, options) {
this.state.leadingGlobstar = true;
}
- var next = this.next();
var prev = this.prev();
- var next2 = this.next(2);
- var prev2 = this.prev(2);
+ var before = this.prev(2);
+ var next = this.next();
+ var after = this.next(2);
var type = prev.type;
var val = node.val;
if (prev.type === 'slash' && next.type === 'slash') {
- if (prev2.type === 'text') {
+ if (before.type === 'text') {
this.output += '?';
- if (next2.type !== 'text') {
+ if (after.type !== 'text') {
this.output += '\\b';
}
}
@@ -206,20 +227,21 @@ module.exports = function(nanomatch, options) {
parsed = parsed.slice(1);
}
- if (parsed && type !== 'slash' && type !== 'bos') {
- val = star;
+ var isInside = node.isInside.paren || node.isInside.brace;
+ if (parsed && type !== 'slash' && type !== 'bos' && !isInside) {
+ val = star();
} else {
val = this.options.dot !== true
- ? '(?:(?!(?:\\/|^)\\.).)*?'
- : '(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/))(?!\\.{2}).)*?';
+ ? '(?:(?!(?:[' + slash() + ']|^)\\.).)*?'
+ : '(?:(?!(?:[' + slash() + ']|^)(?:\\.{1,2})($|[' + slash() + ']))(?!\\.{2}).)*?';
}
if ((type === 'slash' || type === 'bos') && this.options.dot !== true) {
val = '(?!\\.)' + val;
}
- if (prev.type === 'slash' && next.type === 'slash' && prev2.type !== 'text') {
- if (next2.type === 'text' || next2.type === 'star') {
+ if (prev.type === 'slash' && next.type === 'slash' && before.type !== 'text') {
+ if (after.type === 'text' || after.type === 'star') {
node.addQmark = true;
}
}
@@ -246,23 +268,23 @@ module.exports = function(nanomatch, options) {
}
if (this.output === '' && this.options.contains !== true) {
- this.output = '(?!\\/)';
+ this.output = '(?![' + slash() + '])';
}
if (type === 'bracket' && this.options.bash === false) {
- var str = next && next.type === 'bracket' ? star : '*?';
+ var str = next && next.type === 'bracket' ? star() : '*?';
if (!prev.nodes || prev.nodes[1].type !== 'posix') {
return this.emit(str, node);
}
}
var prefix = !this.dotfiles && type !== 'text' && type !== 'escape'
- ? (this.options.dot ? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))' : '(?!\\.)')
+ ? (this.options.dot ? '(?!(?:^|[' + slash() + '])\\.{1,2}(?:$|[' + slash() + ']))' : '(?!\\.)')
: '';
if (isStart(prev) || (isStart(prior) && type === 'not')) {
if (prefix !== '(?!\\.)') {
- prefix += '(?!(\\.{2}|\\.\\/))(?=.)';
+ prefix += '(?!(\\.{2}|\\.[' + slash() + ']))(?=.)';
} else {
prefix += '(?=.)';
}
@@ -274,7 +296,7 @@ module.exports = function(nanomatch, options) {
this.output = '(?!\\.)' + this.output;
}
- var output = prefix + star;
+ var output = prefix + star();
if (this.options.capture) {
output = '(' + output + ')';
}
@@ -298,9 +320,9 @@ module.exports = function(nanomatch, options) {
var prev = this.prev();
var val = node.val;
- this.output = '(?:(?:\\.(?:\\/|\\\\))(?=.))?' + this.output;
+ this.output = '(?:\\.[' + slash() + '](?=.))?' + this.output;
if (this.state.metachar && prev.type !== 'qmark' && prev.type !== 'slash') {
- val += (this.options.contains ? '(?:\\/|\\\\)?' : '(?:(?:\\/|\\\\)|$)');
+ val += (this.options.contains ? '[' + slash() + ']?' : '(?:[' + slash() + ']|$)');
}
return this.emit(val, node);
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);
}
diff --git a/node_modules/nanomatch/lib/utils.js b/node_modules/nanomatch/lib/utils.js
index 6fc434012..0cf1501d2 100644
--- a/node_modules/nanomatch/lib/utils.js
+++ b/node_modules/nanomatch/lib/utils.js
@@ -7,6 +7,7 @@ var path = require('path');
* Module dependencies
*/
+var isWindows = require('is-windows')();
var Snapdragon = require('snapdragon');
utils.define = require('define-property');
utils.diff = require('arr-diff');
@@ -31,7 +32,7 @@ utils.isEmptyString = function(val) {
*/
utils.isWindows = function() {
- return path.sep === '\\' || process.platform === 'win32';
+ return path.sep === '\\' || isWindows === true;
};
/**
@@ -60,7 +61,7 @@ utils.instantiate = function(ast, options) {
}
utils.define(snapdragon, 'parse', function(str, options) {
- var parsed = Snapdragon.prototype.parse.apply(this, arguments);
+ var parsed = Snapdragon.prototype.parse.call(this, str, options);
parsed.input = str;
// escape unmatched brace/bracket/parens
@@ -148,21 +149,23 @@ utils.isObject = function(val) {
*/
utils.escapeRegex = function(str) {
- return str.replace(/[-[\]{}()^$|*+?.\\\/\s]/g, '\\$&');
+ return str.replace(/[-[\]{}()^$|*+?.\\/\s]/g, '\\$&');
};
/**
- * Combines duplicate characters in the provided string.
- * @param {String} `str`
+ * Combines duplicate characters in the provided `input` string.
+ * @param {String} `input`
* @returns {String}
*/
-utils.combineDuplicates = function(str, val) {
- if (typeof val === 'string') {
- var re = new RegExp('(' + val + ')(?=(?:' + val + ')*\\1)', 'g');
- return str.replace(re, '');
- }
- return str.replace(/(.)(?=.*\1)/g, '');
+utils.combineDupes = function(input, patterns) {
+ patterns = utils.arrayify(patterns).join('|').split('|');
+ patterns = patterns.map(function(s) {
+ return s.replace(/\\?([+*\\/])/g, '\\$1');
+ });
+ var substr = patterns.join('|');
+ var regex = new RegExp('(' + substr + ')(?=\\1)', 'g');
+ return input.replace(regex, '');
};
/**
@@ -170,7 +173,7 @@ utils.combineDuplicates = function(str, val) {
*/
utils.hasSpecialChars = function(str) {
- return /(?:(?:(^|\/)[!.])|[*?+()|\[\]{}]|[+@]\()/.test(str);
+ return /(?:(?:(^|\/)[!.])|[*?+()|[\]{}]|[+@]\()/.test(str);
};
/**
@@ -202,7 +205,7 @@ utils.unescape = function(str) {
*/
utils.stripDrive = function(fp) {
- return utils.isWindows() ? fp.replace(/^[a-z]:[\\\/]+?/i, '/') : fp;
+ return utils.isWindows() ? fp.replace(/^[a-z]:[\\/]+?/i, '/') : fp;
};
/**
@@ -226,7 +229,7 @@ utils.stripPrefix = function(str) {
*/
utils.isSimpleChar = function(str) {
- return str === '' || str === ' ' || str === '.';
+ return str.trim() === '' || str === '.';
};
/**