diff --git a/node_modules/minimatch/README.md b/node_modules/minimatch/README.md index e76774e3dcace..33ede1d6eef25 100644 --- a/node_modules/minimatch/README.md +++ b/node_modules/minimatch/README.md @@ -171,6 +171,27 @@ Suppress the behavior of treating a leading `!` character as negation. Returns from negate expressions the same as if they were not negated. (Ie, true on a hit, false on a miss.) +### partial + +Compare a partial path to a pattern. As long as the parts of the path that +are present are not contradicted by the pattern, it will be treated as a +match. This is useful in applications where you're walking through a +folder structure, and don't yet have the full path, but want to ensure that +you do not walk down paths that can never be a match. + +For example, + +```js +minimatch('/a/b', '/a/*/c/d', { partial: true }) // true, might be /a/b/c/d +minimatch('/a/b', '/**/d', { partial: true }) // true, might be /a/b/.../d +minimatch('/x/y/z', '/a/**/z', { partial: true }) // false, because x !== a +``` + +### allowWindowsEscape + +Windows path separator `\` is by default converted to `/`, which +prohibits the usage of `\` as a escape character. This flag skips that +behavior and allows using the escape character. ## Comparisons to other fnmatch/glob implementations diff --git a/node_modules/minimatch/minimatch.js b/node_modules/minimatch/minimatch.js index 0499a73ab045c..fda45ade7cfc3 100644 --- a/node_modules/minimatch/minimatch.js +++ b/node_modules/minimatch/minimatch.js @@ -1,15 +1,15 @@ module.exports = minimatch minimatch.Minimatch = Minimatch -const path = (() => { try { return require('path') } catch (e) {}})() || { +var path = (function () { try { return require('path') } catch (e) {}}()) || { sep: '/' } minimatch.sep = path.sep -const GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} -const expand = require('brace-expansion') +var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} +var expand = require('brace-expansion') -const plTypes = { +var plTypes = { '!': { open: '(?:(?!(?:', close: '))[^/]*?)'}, '?': { open: '(?:', close: ')?' }, '+': { open: '(?:', close: ')+' }, @@ -19,22 +19,22 @@ const plTypes = { // any single thing other than / // don't need to escape / when using new RegExp() -const qmark = '[^/]' +var qmark = '[^/]' // * => any number of characters -const star = qmark + '*?' +var star = qmark + '*?' // ** when dots are allowed. Anything goes, except .. and . // not (^ or / followed by one or two dots followed by $ or /), // followed by anything, any number of times. -const twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?' +var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?' // not a ^ or / followed by a dot, // followed by anything, any number of times. -const twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?' +var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?' // characters that need to be escaped in RegExp. -const reSpecials = charSet('().*{}+?[]^$\\!') +var reSpecials = charSet('().*{}+?[]^$\\!') // "abc" -> { a:true, b:true, c:true } function charSet (s) { @@ -45,7 +45,7 @@ function charSet (s) { } // normalizes slashes. -const slashSplit = /\/+/ +var slashSplit = /\/+/ minimatch.filter = filter function filter (pattern, options) { @@ -56,9 +56,8 @@ function filter (pattern, options) { } function ext (a, b) { - a = a || {} b = b || {} - const t = {} + var t = {} Object.keys(a).forEach(function (k) { t[k] = a[k] }) @@ -73,16 +72,16 @@ minimatch.defaults = function (def) { return minimatch } - const orig = minimatch + var orig = minimatch - const m = function minimatch (p, pattern, options) { + var m = function minimatch (p, pattern, options) { return orig(p, pattern, ext(def, options)) } m.Minimatch = function Minimatch (pattern, options) { return new orig.Minimatch(pattern, ext(def, options)) } - m.Minimatch.defaults = options => { + m.Minimatch.defaults = function defaults (options) { return orig.defaults(ext(def, options)).Minimatch } @@ -123,9 +122,6 @@ function minimatch (p, pattern, options) { return false } - // "" only matches "" - if (pattern.trim() === '') return p === '' - return new Minimatch(pattern, options).match(p) } @@ -137,10 +133,11 @@ function Minimatch (pattern, options) { assertValidPattern(pattern) if (!options) options = {} + pattern = pattern.trim() // windows support: need to use /, not \ - if (path.sep !== '/') { + if (!options.allowWindowsEscape && path.sep !== '/') { pattern = pattern.split(path.sep).join('/') } @@ -151,6 +148,7 @@ function Minimatch (pattern, options) { this.negate = false this.comment = false this.empty = false + this.partial = !!options.partial // make the set of regexps etc. this.make() @@ -160,9 +158,6 @@ Minimatch.prototype.debug = function () {} Minimatch.prototype.make = make function make () { - // don't do it more than once. - if (this._made) return - var pattern = this.pattern var options = this.options @@ -182,7 +177,7 @@ function make () { // step 2: expand braces var set = this.globSet = this.braceExpand() - if (options.debug) this.debug = console.error + if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) } this.debug(this.pattern, set) @@ -264,6 +259,8 @@ function braceExpand (pattern, options) { assertValidPattern(pattern) + // Thanks to Yeting Li for + // improving this regexp to avoid a ReDOS vulnerability. if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) { // shortcut. no need to expand. return [pattern] @@ -272,8 +269,8 @@ function braceExpand (pattern, options) { return expand(pattern) } -const MAX_PATTERN_LENGTH = 1024 * 64 -const assertValidPattern = pattern => { +var MAX_PATTERN_LENGTH = 1024 * 64 +var assertValidPattern = function (pattern) { if (typeof pattern !== 'string') { throw new TypeError('invalid pattern') } @@ -295,18 +292,23 @@ const assertValidPattern = pattern => { // of * is equivalent to a single *. Globstar behavior is enabled by // default, and can be disabled by setting options.noglobstar. Minimatch.prototype.parse = parse -const SUBPARSE = {} +var SUBPARSE = {} function parse (pattern, isSub) { assertValidPattern(pattern) var options = this.options // shortcuts - if (!options.noglobstar && pattern === '**') return GLOBSTAR + if (pattern === '**') { + if (!options.noglobstar) + return GLOBSTAR + else + pattern = '*' + } if (pattern === '') return '' var re = '' - var hasMagic = false + var hasMagic = !!options.nocase var escaping = false // ? => one single character var patternListStack = [] @@ -358,7 +360,8 @@ function parse (pattern, isSub) { } switch (c) { - case '/': /* istanbul ignore next */ { + /* istanbul ignore next */ + case '/': { // completely not allowed, even escaped. // Should already be path-split by now. return false @@ -481,25 +484,23 @@ function parse (pattern, isSub) { // handle the case where we left a class open. // "[z-a]" is valid, equivalent to "\[z-a\]" - if (inClass) { - // split where the last [ was, make sure we don't have - // an invalid re. if so, re-walk the contents of the - // would-be class to re-translate any characters that - // were passed through as-is - // TODO: It would probably be faster to determine this - // without a try/catch and a new RegExp, but it's tricky - // to do safely. For now, this is safe and works. - var cs = pattern.substring(classStart + 1, i) - try { - RegExp('[' + cs + ']') - } catch (er) { - // not a valid class! - var sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' - hasMagic = hasMagic || sp[1] - inClass = false - continue - } + // split where the last [ was, make sure we don't have + // an invalid re. if so, re-walk the contents of the + // would-be class to re-translate any characters that + // were passed through as-is + // TODO: It would probably be faster to determine this + // without a try/catch and a new RegExp, but it's tricky + // to do safely. For now, this is safe and works. + var cs = pattern.substring(classStart + 1, i) + try { + RegExp('[' + cs + ']') + } catch (er) { + // not a valid class! + var sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' + hasMagic = hasMagic || sp[1] + inClass = false + continue } // finish up the class. @@ -583,9 +584,7 @@ function parse (pattern, isSub) { // something that could conceivably capture a dot var addPatternStart = false switch (re.charAt(0)) { - case '.': - case '[': - case '(': addPatternStart = true + case '[': case '.': case '(': addPatternStart = true } // Hack to work around lack of negative lookbehind in JS @@ -713,7 +712,7 @@ function makeRe () { minimatch.match = function (list, pattern, options) { options = options || {} - const mm = new Minimatch(pattern, options) + var mm = new Minimatch(pattern, options) list = list.filter(function (f) { return mm.match(f) }) @@ -723,8 +722,8 @@ minimatch.match = function (list, pattern, options) { return list } -Minimatch.prototype.match = match -function match (f, partial) { +Minimatch.prototype.match = function match (f, partial) { + if (typeof partial === 'undefined') partial = this.partial this.debug('match', f, this.pattern) // short-circuit in the case of busted things. // comments, etc. @@ -894,11 +893,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // patterns with magic have been turned into regexps. var hit if (typeof p === 'string') { - if (options.nocase) { - hit = f.toLowerCase() === p.toLowerCase() - } else { - hit = f === p - } + hit = f === p this.debug('string match', p, f, hit) } else { hit = f.match(p) diff --git a/node_modules/minimatch/package.json b/node_modules/minimatch/package.json index 124df74b6cf81..7384e4aef4761 100644 --- a/node_modules/minimatch/package.json +++ b/node_modules/minimatch/package.json @@ -1,19 +1,19 @@ { - "_from": "minimatch@3.0.5", - "_id": "minimatch@3.0.5", + "_from": "minimatch@3.1.2", + "_id": "minimatch@3.1.2", "_inBundle": false, - "_integrity": "sha512-tUpxzX0VAzJHjLu0xUfFv1gwVp9ba3IOuRAVH2EGuRW8a5emA2FlACLqiT/lDVtS1W+TGNwqz3sWaNyLgDJWuw==", + "_integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "_location": "/minimatch", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "minimatch@3.0.5", + "raw": "minimatch@3.1.2", "name": "minimatch", "escapedName": "minimatch", - "rawSpec": "3.0.5", + "rawSpec": "3.1.2", "saveSpec": null, - "fetchSpec": "3.0.5" + "fetchSpec": "3.1.2" }, "_requiredBy": [ "#USER", @@ -21,14 +21,13 @@ "/eslint", "/eslint-plugin-import", "/eslint-plugin-node", - "/glob", "/ignore-walk", "/pacote", "/test-exclude" ], - "_resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.5.tgz", - "_shasum": "4da8f1290ee0f0f8e83d60ca69f8f134068604a3", - "_spec": "minimatch@3.0.5", + "_resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "_shasum": "19cd194bfd3e428f049a70817c038d89ab4be35b", + "_spec": "minimatch@3.1.2", "_where": "/Users/darcyclarke/Documents/Repos/npm/v6", "author": { "name": "Isaac Z. Schlueter", @@ -57,6 +56,9 @@ "license": "ISC", "main": "minimatch.js", "name": "minimatch", + "publishConfig": { + "tag": "v3-legacy" + }, "repository": { "type": "git", "url": "git://github.com/isaacs/minimatch.git" @@ -67,5 +69,5 @@ "preversion": "npm test", "test": "tap" }, - "version": "3.0.5" + "version": "3.1.2" } diff --git a/package-lock.json b/package-lock.json index 974def5199dac..009ddbe4bd5ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4868,9 +4868,9 @@ "dev": true }, "minimatch": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.5.tgz", - "integrity": "sha512-tUpxzX0VAzJHjLu0xUfFv1gwVp9ba3IOuRAVH2EGuRW8a5emA2FlACLqiT/lDVtS1W+TGNwqz3sWaNyLgDJWuw==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "requires": { "brace-expansion": "^1.1.7" } diff --git a/package.json b/package.json index 634dd1d20c95f..f5b0eeacd4f40 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "lodash.without": "~4.4.0", "lru-cache": "^5.1.1", "meant": "^1.0.3", - "minimatch": "^3.0.5", + "minimatch": "^3.1.2", "mississippi": "^3.0.0", "mkdirp": "^0.5.5", "move-concurrently": "^1.0.1",