diff options
author | isaacs <i@izs.me> | 2012-03-27 10:49:45 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-03-27 11:17:35 +0400 |
commit | 50f321bcfa0e07d18a159a6b36c527a2e55c50c1 (patch) | |
tree | fd19f834df7adae6c5778d10aabbfccf327444b6 /node_modules/minimatch | |
parent | ed2a3c1090aa4c70d6ca1dbf949142600895c451 (diff) |
pull minimatch leftwards
Diffstat (limited to 'node_modules/minimatch')
-rw-r--r-- | node_modules/minimatch/README.md | 14 | ||||
-rw-r--r-- | node_modules/minimatch/minimatch.js | 46 | ||||
-rw-r--r-- | node_modules/minimatch/package.json | 29 |
3 files changed, 43 insertions, 46 deletions
diff --git a/node_modules/minimatch/README.md b/node_modules/minimatch/README.md index d5f97234c..6fd07d2e9 100644 --- a/node_modules/minimatch/README.md +++ b/node_modules/minimatch/README.md @@ -60,11 +60,12 @@ thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but `a/**b` will not. **Note that this is different from the way that `**` is handled by ruby's `Dir` class.** -If an escaped pattern has no matches, and the `null` flag is not set, +If an escaped pattern has no matches, and the `nonull` flag is set, then minimatch.match returns the pattern as-provided, rather than interpreting the character escapes. For example, `minimatch.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than -`"*a?"`. +`"*a?"`. This is akin to setting the `nullglob` option in bash, except +that it does not resolve escaped pattern characters. If brace expansion is not disabled, then it is performed before any other interpretation of the glob pattern. Thus, a pattern like @@ -147,8 +148,8 @@ var javascripts = fileList.filter(minimatch.filter("*.js", {matchBase: true})) ### minimatch.match(list, pattern, options) Match against the list of -files, in the style of fnmatch or glob. If nothing is matched, then -return the pattern (unless `{ null: true }` in the options.) +files, in the style of fnmatch or glob. If nothing is matched, and +options.nonull is set, then return a list containing the pattern itself. ```javascript var javascripts = minimatch.match(fileList, "*.js", {matchBase: true})) @@ -210,3 +211,8 @@ comment. ### nonegate Suppress the behavior of treating a leading `!` character as negation. + +### flipNegate + +Returns from negate expressions the same as if they were not negated. +(Ie, true on a hit, false on a miss.) diff --git a/node_modules/minimatch/minimatch.js b/node_modules/minimatch/minimatch.js index 5ca6008f9..1ca08104e 100644 --- a/node_modules/minimatch/minimatch.js +++ b/node_modules/minimatch/minimatch.js @@ -4,7 +4,6 @@ minimatch.Minimatch = Minimatch var LRU = require("lru-cache") , cache = minimatch.cache = new LRU(100) , GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} - , pathSplit = process.platform === "win32" ? /\\|\// : "/" var path = require("path") // any single thing other than / @@ -130,7 +129,7 @@ function make () { this.parseNegate() // step 2: expand braces - var set = this.braceExpand() + var set = this.globSet = this.braceExpand() if (options.debug) console.error(this.pattern, set) @@ -139,7 +138,7 @@ function make () { // These will be regexps, except in the case of "**", which is // set to the GLOBSTAR object for globstar behavior, // and will not contain any / characters - set = set.map(function (s) { + set = this.globParts = set.map(function (s) { return s.split(slashSplit) }) @@ -159,36 +158,6 @@ function make () { if (options.debug) console.error(this.pattern, set) - // step 4: if we have a defined root, then patterns starting with "" - // get attached to that. If we have a defined cwd, then patterns - // *not* starting with "" get attached to that. - // Exception 1: on windows, a pattern like //\?/c:/ or c:/ will - // not get anything prefixed to it. - // Exception 2: If matchBase is set, and it's just a filename, - // then don't prefix anything onto it, since it'll only match - // files with that basename anyhow. - set = set.map(function (p) { - if (process.platform === "win32" && - ( (p[0] === "" && p[1] === "" && p[2] === "\\?") // unc - || (typeof p[0] === "string" && p[0].match(/^[a-zA-Z]:$/)) )) { - return p - } - if (options.matchBase && p.length === 1) return p - // do prefixing. - if (options.root && p[0] === "") { - var r = options.root.split(pathSplit) - if (r[r.length - 1] === "") r.pop() - r = r.concat(p.slice(1)) - r.absolute = true - return r - } - if (options.cwd && p[0] !== "") { - return options.cwd.split(pathSplit).concat(p) - } - return p - }) - - this.set = set } @@ -549,7 +518,8 @@ function parse (pattern, isSub) { patternListStack.push({ type: plType , start: i - 1 , reStart: re.length }) - re += stateChar === "!" ? "(?!" : "(?:" + // negation is (?:(?!js)[^/]*) + re += stateChar === "!" ? "(?:(?!" : "(?:" stateChar = false continue @@ -562,11 +532,15 @@ function parse (pattern, isSub) { hasMagic = true re += ")" plType = patternListStack.pop().type + // negation is (?:(?!js)[^/]*) + // The others are (?:<pattern>)<type> switch (plType) { + case "!": + re += "[^/]*?)" + break case "?": case "+": case "*": re += plType - case "!": // already handled by the start case "@": break // the default anyway } continue @@ -821,12 +795,14 @@ function match (f, partial) { var pattern = set[i] var hit = this.matchOne(f, pattern, partial) if (hit) { + if (options.flipNegate) return true return !this.negate } } // didn't get any hits. this is success if it's a negative // pattern, failure otherwise. + if (options.flipNegate) return false return this.negate } diff --git a/node_modules/minimatch/package.json b/node_modules/minimatch/package.json index 2816a8405..1bcb3d43e 100644 --- a/node_modules/minimatch/package.json +++ b/node_modules/minimatch/package.json @@ -1,8 +1,12 @@ { - "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)", + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me" + }, "name": "minimatch", "description": "a glob matcher in javascript", - "version": "0.1.5", + "version": "0.2.2", "repository": { "type": "git", "url": "git://github.com/isaacs/minimatch.git" @@ -18,12 +22,23 @@ "lru-cache": "~1.0.5" }, "devDependencies": { - "tap": "~0.1.3" + "tap": "" }, - "licenses" : [ + "licenses": [ { - "type" : "MIT", - "url" : "http://github.com/isaacs/minimatch/raw/master/LICENSE" + "type": "MIT", + "url": "http://github.com/isaacs/minimatch/raw/master/LICENSE" } - ] + ], + "_npmUser": { + "name": "isaacs", + "email": "i@izs.me" + }, + "_id": "minimatch@0.2.2", + "optionalDependencies": {}, + "_engineSupported": true, + "_npmVersion": "1.1.12", + "_nodeVersion": "v0.7.7-pre", + "_defaultsLoaded": true, + "_from": "minimatch@0" } |