Initial commit
This commit is contained in:
21
node_modules/expand-brackets/LICENSE
generated
vendored
Normal file
21
node_modules/expand-brackets/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-2016, Jon Schlinkert
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
211
node_modules/expand-brackets/index.js
generated
vendored
Normal file
211
node_modules/expand-brackets/index.js
generated
vendored
Normal file
@@ -0,0 +1,211 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Local dependencies
|
||||
*/
|
||||
|
||||
var compilers = require('./lib/compilers');
|
||||
var parsers = require('./lib/parsers');
|
||||
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
var debug = require('debug')('expand-brackets');
|
||||
var extend = require('extend-shallow');
|
||||
var Snapdragon = require('snapdragon');
|
||||
var toRegex = require('to-regex');
|
||||
|
||||
/**
|
||||
* Parses the given POSIX character class `pattern` and returns a
|
||||
* string that can be used for creating regular expressions for matching.
|
||||
*
|
||||
* @param {String} `pattern`
|
||||
* @param {Object} `options`
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function brackets(pattern, options) {
|
||||
debug('initializing from <%s>', __filename);
|
||||
var res = brackets.create(pattern, options);
|
||||
return res.output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes an array of strings and a POSIX character class pattern, and returns a new
|
||||
* array with only the strings that matched the pattern.
|
||||
*
|
||||
* ```js
|
||||
* var brackets = require('expand-brackets');
|
||||
* console.log(brackets.match(['1', 'a', 'ab'], '[[:alpha:]]'));
|
||||
* //=> ['a']
|
||||
*
|
||||
* console.log(brackets.match(['1', 'a', 'ab'], '[[:alpha:]]+'));
|
||||
* //=> ['a', 'ab']
|
||||
* ```
|
||||
* @param {Array} `arr` Array of strings to match
|
||||
* @param {String} `pattern` POSIX character class pattern(s)
|
||||
* @param {Object} `options`
|
||||
* @return {Array}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
brackets.match = function(arr, pattern, options) {
|
||||
arr = [].concat(arr);
|
||||
var opts = extend({}, options);
|
||||
var isMatch = brackets.matcher(pattern, opts);
|
||||
var len = arr.length;
|
||||
var idx = -1;
|
||||
var res = [];
|
||||
|
||||
while (++idx < len) {
|
||||
var ele = arr[idx];
|
||||
if (isMatch(ele)) {
|
||||
res.push(ele);
|
||||
}
|
||||
}
|
||||
|
||||
if (res.length === 0) {
|
||||
if (opts.failglob === true) {
|
||||
throw new Error('no matches found for "' + pattern + '"');
|
||||
}
|
||||
|
||||
if (opts.nonull === true || opts.nullglob === true) {
|
||||
return [pattern.split('\\').join('')];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the specified `string` matches the given
|
||||
* brackets `pattern`.
|
||||
*
|
||||
* ```js
|
||||
* var brackets = require('expand-brackets');
|
||||
*
|
||||
* console.log(brackets.isMatch('a.a', '[[:alpha:]].[[:alpha:]]'));
|
||||
* //=> true
|
||||
* console.log(brackets.isMatch('1.2', '[[:alpha:]].[[:alpha:]]'));
|
||||
* //=> false
|
||||
* ```
|
||||
* @param {String} `string` String to match
|
||||
* @param {String} `pattern` Poxis pattern
|
||||
* @param {String} `options`
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
brackets.isMatch = function(str, pattern, options) {
|
||||
return brackets.matcher(pattern, options)(str);
|
||||
};
|
||||
|
||||
/**
|
||||
* Takes a POSIX character class pattern and returns a matcher function. The returned
|
||||
* function takes the string to match as its only argument.
|
||||
*
|
||||
* ```js
|
||||
* var brackets = require('expand-brackets');
|
||||
* var isMatch = brackets.matcher('[[:lower:]].[[:upper:]]');
|
||||
*
|
||||
* console.log(isMatch('a.a'));
|
||||
* //=> false
|
||||
* console.log(isMatch('a.A'));
|
||||
* //=> true
|
||||
* ```
|
||||
* @param {String} `pattern` Poxis pattern
|
||||
* @param {String} `options`
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
brackets.matcher = function(pattern, options) {
|
||||
var re = brackets.makeRe(pattern, options);
|
||||
return function(str) {
|
||||
return re.test(str);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a regular expression from the given `pattern`.
|
||||
*
|
||||
* ```js
|
||||
* var brackets = require('expand-brackets');
|
||||
* var re = brackets.makeRe('[[:alpha:]]');
|
||||
* console.log(re);
|
||||
* //=> /^(?:[a-zA-Z])$/
|
||||
* ```
|
||||
* @param {String} `pattern` The pattern to convert to regex.
|
||||
* @param {Object} `options`
|
||||
* @return {RegExp}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
brackets.makeRe = function(pattern, options) {
|
||||
var res = brackets.create(pattern, options);
|
||||
var opts = extend({strictErrors: false}, options);
|
||||
return toRegex(res.output, opts);
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses the given POSIX character class `pattern` and returns an object
|
||||
* with the compiled `output` and optional source `map`.
|
||||
*
|
||||
* ```js
|
||||
* var brackets = require('expand-brackets');
|
||||
* console.log(brackets('[[:alpha:]]'));
|
||||
* // { options: { source: 'string' },
|
||||
* // input: '[[:alpha:]]',
|
||||
* // state: {},
|
||||
* // compilers:
|
||||
* // { eos: [Function],
|
||||
* // noop: [Function],
|
||||
* // bos: [Function],
|
||||
* // not: [Function],
|
||||
* // escape: [Function],
|
||||
* // text: [Function],
|
||||
* // posix: [Function],
|
||||
* // bracket: [Function],
|
||||
* // 'bracket.open': [Function],
|
||||
* // 'bracket.inner': [Function],
|
||||
* // 'bracket.literal': [Function],
|
||||
* // 'bracket.close': [Function] },
|
||||
* // output: '[a-zA-Z]',
|
||||
* // ast:
|
||||
* // { type: 'root',
|
||||
* // errors: [],
|
||||
* // nodes: [ [Object], [Object], [Object] ] },
|
||||
* // parsingErrors: [] }
|
||||
* ```
|
||||
* @param {String} `pattern`
|
||||
* @param {Object} `options`
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
brackets.create = function(pattern, options) {
|
||||
var snapdragon = (options && options.snapdragon) || new Snapdragon(options);
|
||||
compilers(snapdragon);
|
||||
parsers(snapdragon);
|
||||
|
||||
var ast = snapdragon.parse(pattern, options);
|
||||
ast.input = pattern;
|
||||
var res = snapdragon.compile(ast, options);
|
||||
res.input = pattern;
|
||||
return res;
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose `brackets` constructor, parsers and compilers
|
||||
*/
|
||||
|
||||
brackets.compilers = compilers;
|
||||
brackets.parsers = parsers;
|
||||
|
||||
/**
|
||||
* Expose `brackets`
|
||||
* @type {Function}
|
||||
*/
|
||||
|
||||
module.exports = brackets;
|
||||
87
node_modules/expand-brackets/lib/compilers.js
generated
vendored
Normal file
87
node_modules/expand-brackets/lib/compilers.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
'use strict';
|
||||
|
||||
var posix = require('posix-character-classes');
|
||||
|
||||
module.exports = function(brackets) {
|
||||
brackets.compiler
|
||||
|
||||
/**
|
||||
* Escaped characters
|
||||
*/
|
||||
|
||||
.set('escape', function(node) {
|
||||
return this.emit('\\' + node.val.replace(/^\\/, ''), node);
|
||||
})
|
||||
|
||||
/**
|
||||
* Text
|
||||
*/
|
||||
|
||||
.set('text', function(node) {
|
||||
return this.emit(node.val.replace(/([{}])/g, '\\$1'), node);
|
||||
})
|
||||
|
||||
/**
|
||||
* POSIX character classes
|
||||
*/
|
||||
|
||||
.set('posix', function(node) {
|
||||
if (node.val === '[::]') {
|
||||
return this.emit('\\[::\\]', node);
|
||||
}
|
||||
|
||||
var val = posix[node.inner];
|
||||
if (typeof val === 'undefined') {
|
||||
val = '[' + node.inner + ']';
|
||||
}
|
||||
return this.emit(val, node);
|
||||
})
|
||||
|
||||
/**
|
||||
* Non-posix brackets
|
||||
*/
|
||||
|
||||
.set('bracket', function(node) {
|
||||
return this.mapVisit(node.nodes);
|
||||
})
|
||||
.set('bracket.open', function(node) {
|
||||
return this.emit(node.val, node);
|
||||
})
|
||||
.set('bracket.inner', function(node) {
|
||||
var inner = node.val;
|
||||
|
||||
if (inner === '[' || inner === ']') {
|
||||
return this.emit('\\' + node.val, node);
|
||||
}
|
||||
if (inner === '^]') {
|
||||
return this.emit('^\\]', node);
|
||||
}
|
||||
if (inner === '^') {
|
||||
return this.emit('^', node);
|
||||
}
|
||||
|
||||
if (/-/.test(inner) && !/(\d-\d|\w-\w)/.test(inner)) {
|
||||
inner = inner.split('-').join('\\-');
|
||||
}
|
||||
|
||||
var isNegated = inner.charAt(0) === '^';
|
||||
// add slashes to negated brackets, per spec
|
||||
if (isNegated && inner.indexOf('/') === -1) {
|
||||
inner += '/';
|
||||
}
|
||||
if (isNegated && inner.indexOf('.') === -1) {
|
||||
inner += '.';
|
||||
}
|
||||
|
||||
// don't unescape `0` (octal literal)
|
||||
inner = inner.replace(/\\([1-9])/g, '$1');
|
||||
return this.emit(inner, node);
|
||||
})
|
||||
.set('bracket.close', function(node) {
|
||||
var val = node.val.replace(/^\\/, '');
|
||||
if (node.parent.escaped === true) {
|
||||
return this.emit('\\' + val, node);
|
||||
}
|
||||
return this.emit(val, node);
|
||||
});
|
||||
};
|
||||
219
node_modules/expand-brackets/lib/parsers.js
generated
vendored
Normal file
219
node_modules/expand-brackets/lib/parsers.js
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
'use strict';
|
||||
|
||||
var utils = require('./utils');
|
||||
var define = require('define-property');
|
||||
|
||||
/**
|
||||
* Text regex
|
||||
*/
|
||||
|
||||
var TEXT_REGEX = '(\\[(?=.*\\])|\\])+';
|
||||
var not = utils.createRegex(TEXT_REGEX);
|
||||
|
||||
/**
|
||||
* Brackets parsers
|
||||
*/
|
||||
|
||||
function parsers(brackets) {
|
||||
brackets.state = brackets.state || {};
|
||||
brackets.parser.sets.bracket = brackets.parser.sets.bracket || [];
|
||||
brackets.parser
|
||||
|
||||
.capture('escape', function() {
|
||||
if (this.isInside('bracket')) return;
|
||||
var pos = this.position();
|
||||
var m = this.match(/^\\(.)/);
|
||||
if (!m) return;
|
||||
|
||||
return pos({
|
||||
type: 'escape',
|
||||
val: m[0]
|
||||
});
|
||||
})
|
||||
|
||||
/**
|
||||
* Text parser
|
||||
*/
|
||||
|
||||
.capture('text', function() {
|
||||
if (this.isInside('bracket')) return;
|
||||
var pos = this.position();
|
||||
var m = this.match(not);
|
||||
if (!m || !m[0]) return;
|
||||
|
||||
return pos({
|
||||
type: 'text',
|
||||
val: m[0]
|
||||
});
|
||||
})
|
||||
|
||||
/**
|
||||
* POSIX character classes: "[[:alpha:][:digits:]]"
|
||||
*/
|
||||
|
||||
.capture('posix', function() {
|
||||
var pos = this.position();
|
||||
var m = this.match(/^\[:(.*?):\](?=.*\])/);
|
||||
if (!m) return;
|
||||
|
||||
var inside = this.isInside('bracket');
|
||||
if (inside) {
|
||||
brackets.posix++;
|
||||
}
|
||||
|
||||
return pos({
|
||||
type: 'posix',
|
||||
insideBracket: inside,
|
||||
inner: m[1],
|
||||
val: m[0]
|
||||
});
|
||||
})
|
||||
|
||||
/**
|
||||
* Bracket (noop)
|
||||
*/
|
||||
|
||||
.capture('bracket', function() {})
|
||||
|
||||
/**
|
||||
* Open: '['
|
||||
*/
|
||||
|
||||
.capture('bracket.open', function() {
|
||||
var parsed = this.parsed;
|
||||
var pos = this.position();
|
||||
var m = this.match(/^\[(?=.*\])/);
|
||||
if (!m) return;
|
||||
|
||||
var prev = this.prev();
|
||||
var last = utils.last(prev.nodes);
|
||||
|
||||
if (parsed.slice(-1) === '\\' && !this.isInside('bracket')) {
|
||||
last.val = last.val.slice(0, last.val.length - 1);
|
||||
return pos({
|
||||
type: 'escape',
|
||||
val: m[0]
|
||||
});
|
||||
}
|
||||
|
||||
var open = pos({
|
||||
type: 'bracket.open',
|
||||
val: m[0]
|
||||
});
|
||||
|
||||
if (last.type === 'bracket.open' || this.isInside('bracket')) {
|
||||
open.val = '\\' + open.val;
|
||||
open.type = 'bracket.inner';
|
||||
open.escaped = true;
|
||||
return open;
|
||||
}
|
||||
|
||||
var node = pos({
|
||||
type: 'bracket',
|
||||
nodes: [open]
|
||||
});
|
||||
|
||||
define(node, 'parent', prev);
|
||||
define(open, 'parent', node);
|
||||
this.push('bracket', node);
|
||||
prev.nodes.push(node);
|
||||
})
|
||||
|
||||
/**
|
||||
* Bracket text
|
||||
*/
|
||||
|
||||
.capture('bracket.inner', function() {
|
||||
if (!this.isInside('bracket')) return;
|
||||
var pos = this.position();
|
||||
var m = this.match(not);
|
||||
if (!m || !m[0]) return;
|
||||
|
||||
var next = this.input.charAt(0);
|
||||
var val = m[0];
|
||||
|
||||
var node = pos({
|
||||
type: 'bracket.inner',
|
||||
val: val
|
||||
});
|
||||
|
||||
if (val === '\\\\') {
|
||||
return node;
|
||||
}
|
||||
|
||||
var first = val.charAt(0);
|
||||
var last = val.slice(-1);
|
||||
|
||||
if (first === '!') {
|
||||
val = '^' + val.slice(1);
|
||||
}
|
||||
|
||||
if (last === '\\' || (val === '^' && next === ']')) {
|
||||
val += this.input[0];
|
||||
this.consume(1);
|
||||
}
|
||||
|
||||
node.val = val;
|
||||
return node;
|
||||
})
|
||||
|
||||
/**
|
||||
* Close: ']'
|
||||
*/
|
||||
|
||||
.capture('bracket.close', function() {
|
||||
var parsed = this.parsed;
|
||||
var pos = this.position();
|
||||
var m = this.match(/^\]/);
|
||||
if (!m) return;
|
||||
|
||||
var prev = this.prev();
|
||||
var last = utils.last(prev.nodes);
|
||||
|
||||
if (parsed.slice(-1) === '\\' && !this.isInside('bracket')) {
|
||||
last.val = last.val.slice(0, last.val.length - 1);
|
||||
|
||||
return pos({
|
||||
type: 'escape',
|
||||
val: m[0]
|
||||
});
|
||||
}
|
||||
|
||||
var node = pos({
|
||||
type: 'bracket.close',
|
||||
rest: this.input,
|
||||
val: m[0]
|
||||
});
|
||||
|
||||
if (last.type === 'bracket.open') {
|
||||
node.type = 'bracket.inner';
|
||||
node.escaped = true;
|
||||
return node;
|
||||
}
|
||||
|
||||
var bracket = this.pop('bracket');
|
||||
if (!this.isType(bracket, 'bracket')) {
|
||||
if (this.options.strict) {
|
||||
throw new Error('missing opening "["');
|
||||
}
|
||||
node.type = 'bracket.inner';
|
||||
node.escaped = true;
|
||||
return node;
|
||||
}
|
||||
|
||||
bracket.nodes.push(node);
|
||||
define(node, 'parent', bracket);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Brackets parsers
|
||||
*/
|
||||
|
||||
module.exports = parsers;
|
||||
|
||||
/**
|
||||
* Expose text regex
|
||||
*/
|
||||
|
||||
module.exports.TEXT_REGEX = TEXT_REGEX;
|
||||
34
node_modules/expand-brackets/lib/utils.js
generated
vendored
Normal file
34
node_modules/expand-brackets/lib/utils.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
var toRegex = require('to-regex');
|
||||
var regexNot = require('regex-not');
|
||||
var cached;
|
||||
|
||||
/**
|
||||
* Get the last element from `array`
|
||||
* @param {Array} `array`
|
||||
* @return {*}
|
||||
*/
|
||||
|
||||
exports.last = function(arr) {
|
||||
return arr[arr.length - 1];
|
||||
};
|
||||
|
||||
/**
|
||||
* Create and cache regex to use for text nodes
|
||||
*/
|
||||
|
||||
exports.createRegex = function(pattern, include) {
|
||||
if (cached) return cached;
|
||||
var opts = {contains: true, strictClose: false};
|
||||
var not = regexNot.create(pattern, opts);
|
||||
var re;
|
||||
|
||||
if (typeof include === 'string') {
|
||||
re = toRegex('^(?:' + include + '|' + not + ')', opts);
|
||||
} else {
|
||||
re = toRegex(not, opts);
|
||||
}
|
||||
|
||||
return (cached = re);
|
||||
};
|
||||
65
node_modules/expand-brackets/package.json
generated
vendored
Normal file
65
node_modules/expand-brackets/package.json
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"name": "expand-brackets",
|
||||
"description": "Expand POSIX bracket expressions (character classes) in glob patterns.",
|
||||
"version": "2.1.4",
|
||||
"homepage": "https://github.com/jonschlinkert/expand-brackets",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"repository": "jonschlinkert/expand-brackets",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "^2.3.3",
|
||||
"define-property": "^0.2.5",
|
||||
"extend-shallow": "^2.0.1",
|
||||
"posix-character-classes": "^0.1.0",
|
||||
"regex-not": "^1.0.0",
|
||||
"snapdragon": "^0.8.1",
|
||||
"to-regex": "^3.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bash-match": "^0.1.1",
|
||||
"gulp-format-md": "^0.1.10",
|
||||
"helper-changelog": "^0.3.0",
|
||||
"minimatch": "^3.0.3",
|
||||
"mocha": "^3.0.2",
|
||||
"multimatch": "^2.1.0",
|
||||
"yargs-parser": "^4.0.0"
|
||||
},
|
||||
"verb": {
|
||||
"run": true,
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"helpers": [
|
||||
"helper-changelog"
|
||||
],
|
||||
"related": {
|
||||
"list": [
|
||||
"braces",
|
||||
"extglob",
|
||||
"micromatch",
|
||||
"nanomatch"
|
||||
]
|
||||
},
|
||||
"reflinks": [
|
||||
"micromatch",
|
||||
"verb",
|
||||
"verb-generate-readme"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user