Initial pass

This commit is contained in:
Danny McCormick
2019-06-26 21:12:00 -04:00
commit 39c08a0eaa
7242 changed files with 1886006 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
## History
### key
Changelog entries are classified using the following labels _(from [keep-a-changelog][]_):
- `added`: for new features
- `changed`: for changes in existing functionality
- `deprecated`: for once-stable features removed in upcoming releases
- `removed`: for deprecated features removed in this release
- `fixed`: for any bug fixes
- `bumped`: updated dependencies, only minor or higher will be listed.
### [1.1.0] - 2017-04-11
**Fixed**
- adds support for unclosed quotes
**Added**
- adds support for `options.noglobstar`
### [1.0.4] - 2017-04-06
Housekeeping updates. Adds documentation section about escaping, cleans up utils.
### [1.0.3] - 2017-04-06
This release includes fixes for windows path edge cases and other improvements for stricter adherence to bash spec.
**Fixed**
- More windows path edge cases
**Added**
- Support for bash-like quoted strings for escaping sequences of characters, such as `foo/"**"/bar` where `**` should be matched literally and not evaluated as special characters.
### [1.0.1] - 2016-12-12
**Added**
- Support for windows path edge cases where backslashes are used in brackets or other unusual combinations.
### [1.0.0] - 2016-12-12
Stable release.
### [0.1.0] - 2016-10-08
First release.
[Unreleased]: https://github.com/jonschlinkert/nanomatch/compare/0.1.0...HEAD
[0.2.0]: https://github.com/jonschlinkert/nanomatch/compare/0.1.0...0.2.0
[keep-a-changelog]: https://github.com/olivierlacan/keep-a-changelog
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016-2018, 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.
+1148
View File
File diff suppressed because one or more lines are too long
+838
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -0,0 +1 @@
module.exports = new (require('fragment-cache'))();
+339
View File
@@ -0,0 +1,339 @@
'use strict';
/**
* Nanomatch compilers
*/
module.exports = function(nanomatch, options) {
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;
nanomatch.compiler.state = ast.state;
nanomatch.compiler
/**
* Negation / escaping
*/
.set('not', function(node) {
var prev = this.prev();
if (this.options.nonegate === true || prev.type !== 'bos') {
return this.emit('\\' + node.val, node);
}
return this.emit(node.val, node);
})
.set('escape', function(node) {
if (this.options.unescape && /^[-\w_.]/.test(node.val)) {
return this.emit(node.val, node);
}
return this.emit('\\' + node.val, node);
})
.set('quoted', function(node) {
return this.emit(node.val, node);
})
/**
* Regex
*/
.set('dollar', function(node) {
if (node.parent.type === 'bracket') {
return this.emit(node.val, node);
}
return this.emit('\\' + node.val, node);
})
/**
* Dot: "."
*/
.set('dot', function(node) {
if (node.dotfiles === true) this.dotfiles = true;
return this.emit('\\' + node.val, node);
})
/**
* Slashes: "/" and "\"
*/
.set('backslash', function(node) {
return this.emit(node.val, node);
})
.set('slash', function(node, nodes, i) {
var val = '[' + slash() + ']';
var parent = node.parent;
var prev = this.prev();
// set "node.hasSlash" to true on all ancestor parens nodes
while (parent.type === 'paren' && !parent.hasSlash) {
parent.hasSlash = true;
parent = parent.parent;
}
if (prev.addQmark) {
val += '?';
}
// word boundary
if (node.rest.slice(0, 2) === '\\b') {
return this.emit(val, node);
}
// globstars
if (node.parsed === '**' || node.parsed === './**') {
this.output = '(?:' + this.output;
return this.emit(val + ')?', node);
}
// negation
if (node.parsed === '!**' && this.options.nonegate !== true) {
return this.emit(val + '?\\b', node);
}
return this.emit(val, node);
})
/**
* Square brackets
*/
.set('bracket', function(node) {
var close = node.close;
var open = !node.escaped ? '[' : '\\[';
var negated = node.negated;
var inner = node.inner;
var val = node.val;
if (node.escaped === true) {
inner = inner.replace(/\\?(\W)/g, '\\$1');
negated = '';
}
if (inner === ']-') {
inner = '\\]\\-';
}
if (negated && inner.indexOf('.') === -1) {
inner += '.';
}
if (negated && inner.indexOf('/') === -1) {
inner += '/';
}
val = open + negated + inner + close;
return this.emit(val, node);
})
/**
* Square: "[.]" (only matches a single character in brackets)
*/
.set('square', function(node) {
var val = (/^\W/.test(node.val) ? '\\' : '') + node.val;
return this.emit(val, node);
})
/**
* Question mark: "?"
*/
.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 = '[^\\\\/]';
}
if (node.parsed.slice(-1) === '(') {
var ch = node.rest.charAt(0);
if (ch === '!' || ch === '=' || ch === ':') {
return this.emit(node.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);
}
if (!this.output || (/[?*+]/.test(ch) && node.parent.type !== 'bracket')) {
return this.emit('\\+', node);
}
var ch = this.output.slice(-1);
if (/\w/.test(ch) && !node.inside) {
return this.emit('+\\+?', node);
}
return this.emit('+', node);
})
/**
* globstar: '**'
*/
.set('globstar', function(node, nodes, i) {
if (!this.output) {
this.state.leadingGlobstar = true;
}
var prev = this.prev();
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 (before.type === 'text') {
this.output += '?';
if (after.type !== 'text') {
this.output += '\\b';
}
}
}
var parsed = node.parsed;
if (parsed.charAt(0) === '!') {
parsed = parsed.slice(1);
}
var isInside = node.isInside.paren || node.isInside.brace;
if (parsed && type !== 'slash' && type !== 'bos' && !isInside) {
val = star();
} else {
val = this.options.dot !== true
? '(?:(?!(?:[' + slash() + ']|^)\\.).)*?'
: '(?:(?!(?:[' + slash() + ']|^)(?:\\.{1,2})($|[' + slash() + ']))(?!\\.{2}).)*?';
}
if ((type === 'slash' || type === 'bos') && this.options.dot !== true) {
val = '(?!\\.)' + val;
}
if (prev.type === 'slash' && next.type === 'slash' && before.type !== 'text') {
if (after.type === 'text' || after.type === 'star') {
node.addQmark = true;
}
}
if (this.options.capture) {
val = '(' + val + ')';
}
return this.emit(val, node);
})
/**
* Star: "*"
*/
.set('star', function(node, nodes, i) {
var prior = nodes[i - 2] || {};
var prev = this.prev();
var next = this.next();
var type = prev.type;
function isStart(n) {
return n.type === 'bos' || n.type === 'slash';
}
if (this.output === '' && this.options.contains !== true) {
this.output = '(?![' + slash() + '])';
}
if (type === 'bracket' && this.options.bash === false) {
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 ? '(?!(?:^|[' + slash() + '])\\.{1,2}(?:$|[' + slash() + ']))' : '(?!\\.)')
: '';
if (isStart(prev) || (isStart(prior) && type === 'not')) {
if (prefix !== '(?!\\.)') {
prefix += '(?!(\\.{2}|\\.[' + slash() + ']))(?=.)';
} else {
prefix += '(?=.)';
}
} else if (prefix === '(?!\\.)') {
prefix = '';
}
if (prev.type === 'not' && prior.type === 'bos' && this.options.dot === true) {
this.output = '(?!\\.)' + this.output;
}
var output = prefix + star();
if (this.options.capture) {
output = '(' + output + ')';
}
return this.emit(output, node);
})
/**
* Text
*/
.set('text', function(node) {
return this.emit(node.val, node);
})
/**
* End-of-string
*/
.set('eos', function(node) {
var prev = this.prev();
var val = node.val;
this.output = '(?:\\.[' + slash() + '](?=.))?' + this.output;
if (this.state.metachar && prev.type !== 'qmark' && prev.type !== 'slash') {
val += (this.options.contains ? '[' + slash() + ']?' : '(?:[' + slash() + ']|$)');
}
return this.emit(val, node);
});
/**
* Allow custom compilers to be passed on options
*/
if (options && typeof options.compilers === 'function') {
options.compilers(nanomatch.compiler);
}
};
+386
View File
@@ -0,0 +1,386 @@
'use strict';
var regexNot = require('regex-not');
var toRegex = require('to-regex');
/**
* Characters to use in negation regex (we want to "not" match
* characters that are matched by other parsers)
*/
var cached;
var NOT_REGEX = '[\\[!*+?$^"\'.\\\\/]+';
var not = createTextRegex(NOT_REGEX);
/**
* Nanomatch parsers
*/
module.exports = function(nanomatch, options) {
var parser = nanomatch.parser;
var opts = parser.options;
parser.state = {
slashes: 0,
paths: []
};
parser.ast.state = parser.state;
parser
/**
* Beginning-of-string
*/
.capture('prefix', function() {
if (this.parsed) return;
var m = this.match(/^\.[\\/]/);
if (!m) return;
this.state.strictOpen = !!this.options.strictOpen;
this.state.addPrefix = true;
})
/**
* Escape: "\\."
*/
.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[2] || m[1]
});
})
/**
* Quoted strings
*/
.capture('quoted', function() {
var pos = this.position();
var m = this.match(/^["']/);
if (!m) return;
var quote = m[0];
if (this.input.indexOf(quote) === -1) {
return pos({
type: 'escape',
val: quote
});
}
var tok = advanceTo(this.input, quote);
this.consume(tok.len);
return pos({
type: 'quoted',
val: tok.esc
});
})
/**
* Negations: "!"
*/
.capture('not', function() {
var parsed = this.parsed;
var pos = this.position();
var m = this.match(this.notRegex || /^!+/);
if (!m) return;
var val = m[0];
var isNegated = (val.length % 2) === 1;
if (parsed === '' && !isNegated) {
val = '';
}
// if nothing has been parsed, we know `!` is at the start,
// so we need to wrap the result in a negation regex
if (parsed === '' && isNegated && this.options.nonegate !== true) {
this.bos.val = '(?!^(?:';
this.append = ')$).*';
val = '';
}
return pos({
type: 'not',
val: val
});
})
/**
* Dot: "."
*/
.capture('dot', function() {
var parsed = this.parsed;
var pos = this.position();
var m = this.match(/^\.+/);
if (!m) return;
var val = m[0];
this.state.dot = val === '.' && (parsed === '' || parsed.slice(-1) === '/');
return pos({
type: 'dot',
dotfiles: this.state.dot,
val: val
});
})
/**
* Plus: "+"
*/
.capture('plus', /^\+(?!\()/)
/**
* Question mark: "?"
*/
.capture('qmark', function() {
var parsed = this.parsed;
var pos = this.position();
var m = this.match(/^\?+(?!\()/);
if (!m) return;
this.state.metachar = true;
this.state.qmark = true;
return pos({
type: 'qmark',
parsed: parsed,
val: m[0]
});
})
/**
* Globstar: "**"
*/
.capture('globstar', function() {
var parsed = this.parsed;
var pos = this.position();
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;
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 = '**';
} else {
this.state.star = true;
node.val = '*';
}
return node;
})
/**
* Star: "*"
*/
.capture('star', function() {
var pos = this.position();
var starRe = /^(?:\*(?![*(])|[*]{3,}(?!\()|[*]{2}(?![(/]|$)|\*(?=\*\())/;
var m = this.match(starRe);
if (!m) return;
this.state.metachar = true;
this.state.star = true;
return pos({
type: 'star',
val: m[0]
});
})
/**
* Slash: "/"
*/
.capture('slash', function() {
var pos = this.position();
var m = this.match(/^\//);
if (!m) return;
this.state.slashes++;
return pos({
type: 'slash',
val: m[0]
});
})
/**
* Backslash: "\\"
*/
.capture('backslash', function() {
var pos = this.position();
var m = this.match(/^\\(?![*+?(){}[\]'"])/);
if (!m) return;
var val = m[0];
if (this.isInside('bracket')) {
val = '\\';
} else if (val.length > 1) {
val = '\\\\';
}
return pos({
type: 'backslash',
val: val
});
})
/**
* Square: "[.]"
*/
.capture('square', function() {
if (this.isInside('bracket')) return;
var pos = this.position();
var m = this.match(/^\[([^!^\\])\]/);
if (!m) return;
return pos({
type: 'square',
val: m[1]
});
})
/**
* Brackets: "[...]" (basic, this can be overridden by other parsers)
*/
.capture('bracket', function() {
var pos = this.position();
var m = this.match(/^(?:\[([!^]?)([^\]]+|\]-)(\]|[^*+?]+)|\[)/);
if (!m) return;
var val = m[0];
var negated = m[1] ? '^' : '';
var inner = (m[2] || '').replace(/\\\\+/, '\\\\');
var close = m[3] || '';
if (m[2] && inner.length < m[2].length) {
val = val.replace(/\\\\+/, '\\\\');
}
var esc = this.input.slice(0, 2);
if (inner === '' && esc === '\\]') {
inner += esc;
this.consume(2);
var str = this.input;
var idx = -1;
var ch;
while ((ch = str[++idx])) {
this.consume(1);
if (ch === ']') {
close = ch;
break;
}
inner += ch;
}
}
return pos({
type: 'bracket',
val: val,
escaped: close !== ']',
negated: negated,
inner: inner,
close: close
});
})
/**
* Text
*/
.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]
});
});
/**
* Allow custom parsers to be passed on options
*/
if (options && typeof options.parsers === 'function') {
options.parsers(nanomatch.parser);
}
};
/**
* Advance to the next non-escaped character
*/
function advanceTo(input, endChar) {
var ch = input.charAt(0);
var tok = { len: 1, val: '', esc: '' };
var idx = 0;
function advance() {
if (ch !== '\\') {
tok.esc += '\\' + ch;
tok.val += ch;
}
ch = input.charAt(++idx);
tok.len++;
if (ch === '\\') {
advance();
advance();
}
}
while (ch && ch !== endChar) {
advance();
}
return tok;
}
/**
* Create text regex
*/
function createTextRegex(pattern) {
if (cached) return cached;
var opts = {contains: true, strictClose: false};
var not = regexNot.create(pattern, opts);
var re = toRegex('^(?:[*]\\((?=.)|' + not + ')', opts);
return (cached = re);
}
/**
* Expose negation string
*/
module.exports.not = NOT_REGEX;
+379
View File
@@ -0,0 +1,379 @@
'use strict';
var utils = module.exports;
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');
utils.extend = require('extend-shallow');
utils.pick = require('object.pick');
utils.typeOf = require('kind-of');
utils.unique = require('array-unique');
/**
* Returns true if the given value is effectively an empty string
*/
utils.isEmptyString = function(val) {
return String(val) === '' || String(val) === './';
};
/**
* Returns true if the platform is windows, or `path.sep` is `\\`.
* This is defined as a function to allow `path.sep` to be set in unit tests,
* or by the user, if there is a reason to do so.
* @return {Boolean}
*/
utils.isWindows = function() {
return path.sep === '\\' || isWindows === true;
};
/**
* Return the last element from an array
*/
utils.last = function(arr, n) {
return arr[arr.length - (n || 1)];
};
/**
* Get the `Snapdragon` instance to use
*/
utils.instantiate = function(ast, options) {
var snapdragon;
// if an instance was created by `.parse`, use that instance
if (utils.typeOf(ast) === 'object' && ast.snapdragon) {
snapdragon = ast.snapdragon;
// if the user supplies an instance on options, use that instance
} else if (utils.typeOf(options) === 'object' && options.snapdragon) {
snapdragon = options.snapdragon;
// create a new instance
} else {
snapdragon = new Snapdragon(options);
}
utils.define(snapdragon, 'parse', function(str, options) {
var parsed = Snapdragon.prototype.parse.call(this, str, options);
parsed.input = str;
// escape unmatched brace/bracket/parens
var last = this.parser.stack.pop();
if (last && this.options.strictErrors !== true) {
var open = last.nodes[0];
var inner = last.nodes[1];
if (last.type === 'bracket') {
if (inner.val.charAt(0) === '[') {
inner.val = '\\' + inner.val;
}
} else {
open.val = '\\' + open.val;
var sibling = open.parent.nodes[1];
if (sibling.type === 'star') {
sibling.loose = true;
}
}
}
// add non-enumerable parser reference
utils.define(parsed, 'parser', this.parser);
return parsed;
});
return snapdragon;
};
/**
* 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) {
if (typeof options === 'undefined') {
return pattern;
}
var key = pattern;
for (var prop in options) {
if (options.hasOwnProperty(prop)) {
key += ';' + prop + '=' + String(options[prop]);
}
}
return key;
};
/**
* Cast `val` to an array
* @return {Array}
*/
utils.arrayify = function(val) {
if (typeof val === 'string') return [val];
return val ? (Array.isArray(val) ? val : [val]) : [];
};
/**
* Return true if `val` is a non-empty string
*/
utils.isString = function(val) {
return typeof val === 'string';
};
/**
* Return true if `val` is a non-empty string
*/
utils.isRegex = function(val) {
return utils.typeOf(val) === 'regexp';
};
/**
* Return true if `val` is a non-empty string
*/
utils.isObject = function(val) {
return utils.typeOf(val) === 'object';
};
/**
* Escape regex characters in the given string
*/
utils.escapeRegex = function(str) {
return str.replace(/[-[\]{}()^$|*+?.\\/\s]/g, '\\$&');
};
/**
* Combines duplicate characters in the provided `input` string.
* @param {String} `input`
* @returns {String}
*/
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, '');
};
/**
* Returns true if the given `str` has special characters
*/
utils.hasSpecialChars = function(str) {
return /(?:(?:(^|\/)[!.])|[*?+()|[\]{}]|[+@]\()/.test(str);
};
/**
* Normalize slashes in the given filepath.
*
* @param {String} `filepath`
* @return {String}
*/
utils.toPosixPath = function(str) {
return str.replace(/\\+/g, '/');
};
/**
* Strip backslashes before special characters in a string.
*
* @param {String} `str`
* @return {String}
*/
utils.unescape = function(str) {
return utils.toPosixPath(str.replace(/\\(?=[*+?!.])/g, ''));
};
/**
* Strip the drive letter from a windows filepath
* @param {String} `fp`
* @return {String}
*/
utils.stripDrive = function(fp) {
return utils.isWindows() ? fp.replace(/^[a-z]:[\\/]+?/i, '/') : fp;
};
/**
* Strip the prefix from a filepath
* @param {String} `fp`
* @return {String}
*/
utils.stripPrefix = function(str) {
if (str.charAt(0) === '.' && (str.charAt(1) === '/' || str.charAt(1) === '\\')) {
return str.slice(2);
}
return str;
};
/**
* Returns true if `str` is a common character that doesn't need
* to be processed to be used for matching.
* @param {String} `str`
* @return {Boolean}
*/
utils.isSimpleChar = function(str) {
return str.trim() === '' || str === '.';
};
/**
* Returns true if the given str is an escaped or
* unescaped path character
*/
utils.isSlash = function(str) {
return str === '/' || str === '\\/' || str === '\\' || str === '\\\\';
};
/**
* Returns a function that returns true if the given
* pattern matches or contains a `filepath`
*
* @param {String} `pattern`
* @return {Function}
*/
utils.matchPath = function(pattern, options) {
return (options && options.contains)
? utils.containsPattern(pattern, options)
: utils.equalsPattern(pattern, options);
};
/**
* Returns true if the given (original) filepath or unixified path are equal
* to the given pattern.
*/
utils._equals = function(filepath, unixPath, pattern) {
return pattern === filepath || pattern === unixPath;
};
/**
* Returns true if the given (original) filepath or unixified path contain
* the given pattern.
*/
utils._contains = function(filepath, unixPath, pattern) {
return filepath.indexOf(pattern) !== -1 || unixPath.indexOf(pattern) !== -1;
};
/**
* Returns a function that returns true if the given
* pattern is the same as a given `filepath`
*
* @param {String} `pattern`
* @return {Function}
*/
utils.equalsPattern = function(pattern, options) {
var unixify = utils.unixify(options);
options = options || {};
return function fn(filepath) {
var equal = utils._equals(filepath, unixify(filepath), pattern);
if (equal === true || options.nocase !== true) {
return equal;
}
var lower = filepath.toLowerCase();
return utils._equals(lower, unixify(lower), pattern);
};
};
/**
* Returns a function that returns true if the given
* pattern contains a `filepath`
*
* @param {String} `pattern`
* @return {Function}
*/
utils.containsPattern = function(pattern, options) {
var unixify = utils.unixify(options);
options = options || {};
return function(filepath) {
var contains = utils._contains(filepath, unixify(filepath), pattern);
if (contains === true || options.nocase !== true) {
return contains;
}
var lower = filepath.toLowerCase();
return utils._contains(lower, unixify(lower), pattern);
};
};
/**
* Returns a function that returns true if the given
* regex matches the `filename` of a file path.
*
* @param {RegExp} `re` Matching regex
* @return {Function}
*/
utils.matchBasename = function(re) {
return function(filepath) {
return re.test(filepath) || re.test(path.basename(filepath));
};
};
/**
* Returns the given value unchanced.
* @return {any}
*/
utils.identity = function(val) {
return val;
};
/**
* Determines the filepath to return based on the provided options.
* @return {any}
*/
utils.value = function(str, unixify, options) {
if (options && options.unixify === false) {
return str;
}
if (options && typeof options.unixify === 'function') {
return options.unixify(str);
}
return unixify(str);
};
/**
* Returns a function that normalizes slashes in a string to forward
* slashes, strips `./` from beginning of paths, and optionally unescapes
* special characters.
* @return {Function}
*/
utils.unixify = function(options) {
var opts = options || {};
return function(filepath) {
if (opts.stripPrefix !== false) {
filepath = utils.stripPrefix(filepath);
}
if (opts.unescape === true) {
filepath = utils.unescape(filepath);
}
if (opts.unixify === true || utils.isWindows()) {
filepath = utils.toPosixPath(filepath);
}
return filepath;
};
};
+175
View File
@@ -0,0 +1,175 @@
{
"_args": [
[
"[email protected]",
"C:\\Users\\Administrator\\Documents\\setup-python"
]
],
"_development": true,
"_from": "[email protected]",
"_id": "[email protected]",
"_inBundle": false,
"_integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==",
"_location": "/nanomatch",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "[email protected]",
"name": "nanomatch",
"escapedName": "nanomatch",
"rawSpec": "1.2.13",
"saveSpec": null,
"fetchSpec": "1.2.13"
},
"_requiredBy": [
"/micromatch"
],
"_resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz",
"_spec": "1.2.13",
"_where": "C:\\Users\\Administrator\\Documents\\setup-python",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"bugs": {
"url": "https://github.com/micromatch/nanomatch/issues"
},
"contributors": [
{
"name": "Devon Govett",
"url": "http://badassjs.com"
},
{
"name": "Jon Schlinkert",
"url": "http://twitter.com/jonschlinkert"
}
],
"dependencies": {
"arr-diff": "^4.0.0",
"array-unique": "^0.3.2",
"define-property": "^2.0.2",
"extend-shallow": "^3.0.2",
"fragment-cache": "^0.2.1",
"is-windows": "^1.0.2",
"kind-of": "^6.0.2",
"object.pick": "^1.3.0",
"regex-not": "^1.0.0",
"snapdragon": "^0.8.1",
"to-regex": "^3.0.1"
},
"description": "Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch, but complete Bash 4.3 wildcard support only (no support for exglobs, posix brackets or braces)",
"devDependencies": {
"bash-match": "^1.0.2",
"for-own": "^1.0.0",
"gulp": "^3.9.1",
"gulp-format-md": "^1.0.0",
"gulp-istanbul": "^1.1.3",
"gulp-mocha": "^5.0.0",
"helper-changelog": "^0.3.0",
"minimatch": "^3.0.4",
"minimist": "^1.2.0",
"mocha": "^3.5.3",
"multimatch": "^2.1.0"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js",
"lib"
],
"homepage": "https://github.com/micromatch/nanomatch",
"keywords": [
"bash",
"expand",
"expansion",
"expression",
"file",
"files",
"filter",
"find",
"glob",
"globbing",
"globs",
"globstar",
"match",
"matcher",
"matches",
"matching",
"micromatch",
"minimatch",
"multimatch",
"nanomatch",
"path",
"pattern",
"patterns",
"regex",
"regexp",
"regular",
"shell",
"wildcard"
],
"license": "MIT",
"lintDeps": {
"dependencies": {
"options": {
"lock": {
"snapdragon": "^0.8.1"
}
}
},
"devDependencies": {
"files": {
"options": {
"ignore": [
"benchmark/**"
]
}
}
}
},
"main": "index.js",
"name": "nanomatch",
"repository": {
"type": "git",
"url": "git+https://github.com/micromatch/nanomatch.git"
},
"scripts": {
"test": "mocha"
},
"verb": {
"toc": "collapsible",
"layout": "default",
"tasks": [
"readme"
],
"helpers": [
"helper-changelog"
],
"plugins": [
"gulp-format-md"
],
"related": {
"list": [
"extglob",
"is-extglob",
"is-glob",
"micromatch"
]
},
"reflinks": [
"expand-brackets",
"expand-tilde",
"glob-object",
"micromatch",
"minimatch",
"options",
"snapdragon"
],
"lint": {
"reflinks": true
}
},
"version": "1.2.13"
}