aboutsummaryrefslogtreecommitdiff
path: root/node_modules/extglob/lib
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/extglob/lib')
-rw-r--r--node_modules/extglob/lib/.DS_Storebin0 -> 6148 bytes
-rw-r--r--node_modules/extglob/lib/compilers.js169
-rw-r--r--node_modules/extglob/lib/extglob.js78
-rw-r--r--node_modules/extglob/lib/parsers.js156
-rw-r--r--node_modules/extglob/lib/utils.js69
5 files changed, 472 insertions, 0 deletions
diff --git a/node_modules/extglob/lib/.DS_Store b/node_modules/extglob/lib/.DS_Store
new file mode 100644
index 0000000..5008ddf
--- /dev/null
+++ b/node_modules/extglob/lib/.DS_Store
Binary files differ
diff --git a/node_modules/extglob/lib/compilers.js b/node_modules/extglob/lib/compilers.js
new file mode 100644
index 0000000..d7bed25
--- /dev/null
+++ b/node_modules/extglob/lib/compilers.js
@@ -0,0 +1,169 @@
+'use strict';
+
+var brackets = require('expand-brackets');
+
+/**
+ * Extglob compilers
+ */
+
+module.exports = function(extglob) {
+ function star() {
+ if (typeof extglob.options.star === 'function') {
+ return extglob.options.star.apply(this, arguments);
+ }
+ if (typeof extglob.options.star === 'string') {
+ return extglob.options.star;
+ }
+ return '.*?';
+ }
+
+ /**
+ * Use `expand-brackets` compilers
+ */
+
+ extglob.use(brackets.compilers);
+ extglob.compiler
+
+ /**
+ * Escaped: "\\*"
+ */
+
+ .set('escape', function(node) {
+ return this.emit(node.val, node);
+ })
+
+ /**
+ * Dot: "."
+ */
+
+ .set('dot', function(node) {
+ return this.emit('\\' + node.val, node);
+ })
+
+ /**
+ * Question mark: "?"
+ */
+
+ .set('qmark', function(node) {
+ var val = '[^\\\\/.]';
+ var prev = this.prev();
+
+ if (node.parsed.slice(-1) === '(') {
+ var ch = node.rest.charAt(0);
+ if (ch !== '!' && ch !== '=' && ch !== ':') {
+ return this.emit(val, node);
+ }
+ return this.emit(node.val, node);
+ }
+
+ if (prev.type === 'text' && prev.val) {
+ return this.emit(val, node);
+ }
+
+ if (node.val.length > 1) {
+ val += '{' + node.val.length + '}';
+ }
+ return this.emit(val, node);
+ })
+
+ /**
+ * Plus: "+"
+ */
+
+ .set('plus', function(node) {
+ var prev = node.parsed.slice(-1);
+ if (prev === ']' || prev === ')') {
+ return this.emit(node.val, node);
+ }
+ var ch = this.output.slice(-1);
+ if (!this.output || (/[?*+]/.test(ch) && node.parent.type !== 'bracket')) {
+ return this.emit('\\+', node);
+ }
+ if (/\w/.test(ch) && !node.inside) {
+ return this.emit('+\\+?', node);
+ }
+ return this.emit('+', node);
+ })
+
+ /**
+ * Star: "*"
+ */
+
+ .set('star', function(node) {
+ var prev = this.prev();
+ var prefix = prev.type !== 'text' && prev.type !== 'escape'
+ ? '(?!\\.)'
+ : '';
+
+ return this.emit(prefix + star.call(this, node), node);
+ })
+
+ /**
+ * Parens
+ */
+
+ .set('paren', function(node) {
+ return this.mapVisit(node.nodes);
+ })
+ .set('paren.open', function(node) {
+ var capture = this.options.capture ? '(' : '';
+
+ switch (node.parent.prefix) {
+ case '!':
+ case '^':
+ return this.emit(capture + '(?:(?!(?:', node);
+ case '*':
+ case '+':
+ case '?':
+ case '@':
+ return this.emit(capture + '(?:', node);
+ default: {
+ var val = node.val;
+ if (this.options.bash === true) {
+ val = '\\' + val;
+ } else if (!this.options.capture && val === '(' && node.parent.rest[0] !== '?') {
+ val += '?:';
+ }
+
+ return this.emit(val, node);
+ }
+ }
+ })
+ .set('paren.close', function(node) {
+ var capture = this.options.capture ? ')' : '';
+
+ switch (node.prefix) {
+ case '!':
+ case '^':
+ var prefix = /^(\)|$)/.test(node.rest) ? '$' : '';
+ var str = star.call(this, node);
+
+ // if the extglob has a slash explicitly defined, we know the user wants
+ // to match slashes, so we need to ensure the "star" regex allows for it
+ if (node.parent.hasSlash && !this.options.star && this.options.slash !== false) {
+ str = '.*?';
+ }
+
+ return this.emit(prefix + ('))' + str + ')') + capture, node);
+ case '*':
+ case '+':
+ case '?':
+ return this.emit(')' + node.prefix + capture, node);
+ case '@':
+ return this.emit(')' + capture, node);
+ default: {
+ var val = (this.options.bash === true ? '\\' : '') + ')';
+ return this.emit(val, node);
+ }
+ }
+ })
+
+ /**
+ * Text
+ */
+
+ .set('text', function(node) {
+ var val = node.val.replace(/[\[\]]/g, '\\$&');
+ return this.emit(val, node);
+ });
+};
diff --git a/node_modules/extglob/lib/extglob.js b/node_modules/extglob/lib/extglob.js
new file mode 100644
index 0000000..015f928
--- /dev/null
+++ b/node_modules/extglob/lib/extglob.js
@@ -0,0 +1,78 @@
+'use strict';
+
+/**
+ * Module dependencies
+ */
+
+var Snapdragon = require('snapdragon');
+var define = require('define-property');
+var extend = require('extend-shallow');
+
+/**
+ * Local dependencies
+ */
+
+var compilers = require('./compilers');
+var parsers = require('./parsers');
+
+/**
+ * Customize Snapdragon parser and renderer
+ */
+
+function Extglob(options) {
+ this.options = extend({source: 'extglob'}, options);
+ this.snapdragon = this.options.snapdragon || new Snapdragon(this.options);
+ this.snapdragon.patterns = this.snapdragon.patterns || {};
+ this.compiler = this.snapdragon.compiler;
+ this.parser = this.snapdragon.parser;
+
+ compilers(this.snapdragon);
+ parsers(this.snapdragon);
+
+ /**
+ * Override Snapdragon `.parse` method
+ */
+
+ define(this.snapdragon, 'parse', function(str, options) {
+ var parsed = Snapdragon.prototype.parse.apply(this, arguments);
+ parsed.input = str;
+
+ // escape unmatched brace/bracket/parens
+ var last = this.parser.stack.pop();
+ if (last && this.options.strict !== true) {
+ var node = last.nodes[0];
+ node.val = '\\' + node.val;
+ var sibling = node.parent.nodes[1];
+ if (sibling.type === 'star') {
+ sibling.loose = true;
+ }
+ }
+
+ // add non-enumerable parser reference
+ define(parsed, 'parser', this.parser);
+ return parsed;
+ });
+
+ /**
+ * Decorate `.parse` method
+ */
+
+ define(this, 'parse', function(ast, options) {
+ return this.snapdragon.parse.apply(this.snapdragon, arguments);
+ });
+
+ /**
+ * Decorate `.compile` method
+ */
+
+ define(this, 'compile', function(ast, options) {
+ return this.snapdragon.compile.apply(this.snapdragon, arguments);
+ });
+
+}
+
+/**
+ * Expose `Extglob`
+ */
+
+module.exports = Extglob;
diff --git a/node_modules/extglob/lib/parsers.js b/node_modules/extglob/lib/parsers.js
new file mode 100644
index 0000000..2ba7352
--- /dev/null
+++ b/node_modules/extglob/lib/parsers.js
@@ -0,0 +1,156 @@
+'use strict';
+
+var brackets = require('expand-brackets');
+var define = require('define-property');
+var utils = require('./utils');
+
+/**
+ * Characters to use in text regex (we want to "not" match
+ * characters that are matched by other parsers)
+ */
+
+var TEXT_REGEX = '([!@*?+]?\\(|\\)|[*?.+\\\\]|\\[:?(?=.*\\])|:?\\])+';
+var not = utils.createRegex(TEXT_REGEX);
+
+/**
+ * Extglob parsers
+ */
+
+function parsers(extglob) {
+ extglob.state = extglob.state || {};
+
+ /**
+ * Use `expand-brackets` parsers
+ */
+
+ extglob.use(brackets.parsers);
+ extglob.parser.sets.paren = extglob.parser.sets.paren || [];
+ extglob.parser
+
+ /**
+ * Extglob open: "*("
+ */
+
+ .capture('paren.open', function() {
+ var parsed = this.parsed;
+ var pos = this.position();
+ var m = this.match(/^([!@*?+])?\(/);
+ if (!m) return;
+
+ var prev = this.prev();
+ var prefix = m[1];
+ var val = m[0];
+
+ var open = pos({
+ type: 'paren.open',
+ parsed: parsed,
+ val: val
+ });
+
+ var node = pos({
+ type: 'paren',
+ prefix: prefix,
+ nodes: [open]
+ });
+
+ // if nested negation extglobs, just cancel them out to simplify
+ if (prefix === '!' && prev.type === 'paren' && prev.prefix === '!') {
+ prev.prefix = '@';
+ node.prefix = '@';
+ }
+
+ define(node, 'rest', this.input);
+ define(node, 'parsed', parsed);
+ define(node, 'parent', prev);
+ define(open, 'parent', node);
+
+ this.push('paren', node);
+ prev.nodes.push(node);
+ })
+
+ /**
+ * Extglob close: ")"
+ */
+
+ .capture('paren.close', function() {
+ var parsed = this.parsed;
+ var pos = this.position();
+ var m = this.match(/^\)/);
+ if (!m) return;
+
+ var parent = this.pop('paren');
+ var node = pos({
+ type: 'paren.close',
+ rest: this.input,
+ parsed: parsed,
+ val: m[0]
+ });
+
+ if (!this.isType(parent, 'paren')) {
+ if (this.options.strict) {
+ throw new Error('missing opening paren: "("');
+ }
+ node.escaped = true;
+ return node;
+ }
+
+ node.prefix = parent.prefix;
+ parent.nodes.push(node);
+ define(node, 'parent', parent);
+ })
+
+ /**
+ * Escape: "\\."
+ */
+
+ .capture('escape', function() {
+ var pos = this.position();
+ var m = this.match(/^\\(.)/);
+ if (!m) return;
+
+ return pos({
+ type: 'escape',
+ val: m[0],
+ ch: m[1]
+ });
+ })
+
+ /**
+ * Question marks: "?"
+ */
+
+ .capture('qmark', function() {
+ var parsed = this.parsed;
+ var pos = this.position();
+ var m = this.match(/^\?+(?!\()/);
+ if (!m) return;
+ extglob.state.metachar = true;
+ return pos({
+ type: 'qmark',
+ rest: this.input,
+ parsed: parsed,
+ val: m[0]
+ });
+ })
+
+ /**
+ * Character parsers
+ */
+
+ .capture('star', /^\*(?!\()/)
+ .capture('plus', /^\+(?!\()/)
+ .capture('dot', /^\./)
+ .capture('text', not);
+};
+
+/**
+ * Expose text regex string
+ */
+
+module.exports.TEXT_REGEX = TEXT_REGEX;
+
+/**
+ * Extglob parsers
+ */
+
+module.exports = parsers;
diff --git a/node_modules/extglob/lib/utils.js b/node_modules/extglob/lib/utils.js
new file mode 100644
index 0000000..37a59fb
--- /dev/null
+++ b/node_modules/extglob/lib/utils.js
@@ -0,0 +1,69 @@
+'use strict';
+
+var regex = require('regex-not');
+var Cache = require('fragment-cache');
+
+/**
+ * Utils
+ */
+
+var utils = module.exports;
+var cache = utils.cache = new Cache();
+
+/**
+ * Cast `val` to an array
+ * @return {Array}
+ */
+
+utils.arrayify = function(val) {
+ if (!Array.isArray(val)) {
+ return [val];
+ }
+ return val;
+};
+
+/**
+ * Memoize a generated regex or function
+ */
+
+utils.memoize = function(type, pattern, options, fn) {
+ var key = utils.createKey(type + pattern, options);
+
+ if (cache.has(type, key)) {
+ return cache.get(type, key);
+ }
+
+ var val = fn(pattern, options);
+ if (options && options.cache === false) {
+ return val;
+ }
+
+ cache.set(type, key, val);
+ return val;
+};
+
+/**
+ * Create the key to use for memoization. The key is generated
+ * by iterating over the options and concatenating key-value pairs
+ * to the pattern string.
+ */
+
+utils.createKey = function(pattern, options) {
+ var key = pattern;
+ if (typeof options === 'undefined') {
+ return key;
+ }
+ for (var prop in options) {
+ key += ';' + prop + '=' + String(options[prop]);
+ }
+ return key;
+};
+
+/**
+ * Create the regex to use for matching text
+ */
+
+utils.createRegex = function(str) {
+ var opts = {contains: true, strictClose: false};
+ return regex(str, opts);
+};