Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-06-12 07:15:28 +0400
committerisaacs <i@izs.me>2012-06-12 07:16:47 +0400
commit7e9e5e463619085deec6a77abca2662999d88b55 (patch)
treec2ef2d453c58792bc6c940327213b8d013ad651a /node_modules/glob
parent62971aa8a157d6d883e32e626a343b46c46e8583 (diff)
Add glob as a dependency
Diffstat (limited to 'node_modules/glob')
-rw-r--r--node_modules/glob/.npmignore2
-rw-r--r--node_modules/glob/.travis.yml4
-rw-r--r--node_modules/glob/LICENCE25
-rw-r--r--node_modules/glob/README.md233
-rw-r--r--node_modules/glob/examples/g.js9
-rw-r--r--node_modules/glob/examples/usr-local.js9
-rw-r--r--node_modules/glob/glob.js601
-rw-r--r--node_modules/glob/package.json38
-rw-r--r--node_modules/glob/test/00-setup.js61
-rw-r--r--node_modules/glob/test/bash-comparison.js119
-rw-r--r--node_modules/glob/test/cwd-test.js55
-rw-r--r--node_modules/glob/test/pause-resume.js98
-rw-r--r--node_modules/glob/test/root-nomount.js39
-rw-r--r--node_modules/glob/test/root.js43
-rw-r--r--node_modules/glob/test/zz-cleanup.js11
15 files changed, 1347 insertions, 0 deletions
diff --git a/node_modules/glob/.npmignore b/node_modules/glob/.npmignore
new file mode 100644
index 000000000..2af4b71c9
--- /dev/null
+++ b/node_modules/glob/.npmignore
@@ -0,0 +1,2 @@
+.*.swp
+test/a/
diff --git a/node_modules/glob/.travis.yml b/node_modules/glob/.travis.yml
new file mode 100644
index 000000000..94cd7f6ba
--- /dev/null
+++ b/node_modules/glob/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - 0.6
+ - 0.7
diff --git a/node_modules/glob/LICENCE b/node_modules/glob/LICENCE
new file mode 100644
index 000000000..74489e2e2
--- /dev/null
+++ b/node_modules/glob/LICENCE
@@ -0,0 +1,25 @@
+Copyright (c) Isaac Z. Schlueter
+All rights reserved.
+
+The BSD License
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/node_modules/glob/README.md b/node_modules/glob/README.md
new file mode 100644
index 000000000..6e27df620
--- /dev/null
+++ b/node_modules/glob/README.md
@@ -0,0 +1,233 @@
+# Glob
+
+This is a glob implementation in JavaScript. It uses the `minimatch`
+library to do its matching.
+
+## Attention: node-glob users!
+
+The API has changed dramatically between 2.x and 3.x. This library is
+now 100% JavaScript, and the integer flags have been replaced with an
+options object.
+
+Also, there's an event emitter class, proper tests, and all the other
+things you've come to expect from node modules.
+
+And best of all, no compilation!
+
+## Usage
+
+```javascript
+var glob = require("glob")
+
+// options is optional
+glob("**/*.js", options, function (er, files) {
+ // files is an array of filenames.
+ // If the `nonull` option is set, and nothing
+ // was found, then files is ["**/*.js"]
+ // er is an error object or null.
+})
+```
+
+## Features
+
+Please see the [minimatch
+documentation](https://github.com/isaacs/minimatch) for more details.
+
+Supports these glob features:
+
+* Brace Expansion
+* Extended glob matching
+* "Globstar" `**` matching
+
+See:
+
+* `man sh`
+* `man bash`
+* `man 3 fnmatch`
+* `man 5 gitignore`
+* [minimatch documentation](https://github.com/isaacs/minimatch)
+
+## glob(pattern, [options], cb)
+
+* `pattern` {String} Pattern to be matched
+* `options` {Object}
+* `cb` {Function}
+ * `err` {Error | null}
+ * `matches` {Array<String>} filenames found matching the pattern
+
+Perform an asynchronous glob search.
+
+## glob.sync(pattern, [options]
+
+* `pattern` {String} Pattern to be matched
+* `options` {Object}
+* return: {Array<String>} filenames found matching the pattern
+
+Perform a synchronous glob search.
+
+## Class: glob.Glob
+
+Create a Glob object by instanting the `glob.Glob` class.
+
+```javascript
+var Glob = require("glob").Glob
+var mg = new Glob(pattern, options, cb)
+```
+
+It's an EventEmitter, and starts walking the filesystem to find matches
+immediately.
+
+### new glob.Glob(pattern, [options], [cb])
+
+* `pattern` {String} pattern to search for
+* `options` {Object}
+* `cb` {Function} Called when an error occurs, or matches are found
+ * `err` {Error | null}
+ * `matches` {Array<String>} filenames found matching the pattern
+
+Note that if the `sync` flag is set in the options, then matches will
+be immediately available on the `g.found` member.
+
+### Properties
+
+* `minimatch` The minimatch object that the glob uses.
+* `options` The options object passed in.
+* `error` The error encountered. When an error is encountered, the
+ glob object is in an undefined state, and should be discarded.
+* `aborted` Boolean which is set to true when calling `abort()`. There
+ is no way at this time to continue a glob search after aborting, but
+ you can re-use the statCache to avoid having to duplicate syscalls.
+
+### Events
+
+* `end` When the matching is finished, this is emitted with all the
+ matches found. If the `nonull` option is set, and no match was found,
+ then the `matches` list contains the original pattern. The matches
+ are sorted, unless the `nosort` flag is set.
+* `match` Every time a match is found, this is emitted with the matched.
+* `error` Emitted when an unexpected error is encountered, or whenever
+ any fs error occurs if `options.strict` is set.
+* `abort` When `abort()` is called, this event is raised.
+
+### Methods
+
+* `abort` Stop the search.
+
+### Options
+
+All the options that can be passed to Minimatch can also be passed to
+Glob to change pattern matching behavior. Also, some have been added,
+or have glob-specific ramifications.
+
+All options are false by default, unless otherwise noted.
+
+All options are added to the glob object, as well.
+
+* `cwd` The current working directory in which to search. Defaults
+ to `process.cwd()`.
+* `root` The place where patterns starting with `/` will be mounted
+ onto. Defaults to `path.resolve(options.cwd, "/")` (`/` on Unix
+ systems, and `C:\` or some such on Windows.)
+* `nomount` By default, a pattern starting with a forward-slash will be
+ "mounted" onto the root setting, so that a valid filesystem path is
+ returned. Set this flag to disable that behavior.
+* `mark` Add a `/` character to directory matches. Note that this
+ requires additional stat calls.
+* `nosort` Don't sort the results.
+* `stat` Set to true to stat *all* results. This reduces performance
+ somewhat, and is completely unnecessary, unless `readdir` is presumed
+ to be an untrustworthy indicator of file existence. It will cause
+ ELOOP to be triggered one level sooner in the case of cyclical
+ symbolic links.
+* `silent` When an unusual error is encountered
+ when attempting to read a directory, a warning will be printed to
+ stderr. Set the `silent` option to true to suppress these warnings.
+* `strict` When an unusual error is encountered
+ when attempting to read a directory, the process will just continue on
+ in search of other matches. Set the `strict` option to raise an error
+ in these cases.
+* `statCache` A cache of results of filesystem information, to prevent
+ unnecessary stat calls. While it should not normally be necessary to
+ set this, you may pass the statCache from one glob() call to the
+ options object of another, if you know that the filesystem will not
+ change between calls. (See "Race Conditions" below.)
+* `sync` Perform a synchronous glob search.
+* `nounique` In some cases, brace-expanded patterns can result in the
+ same file showing up multiple times in the result set. By default,
+ this implementation prevents duplicates in the result set.
+ Set this flag to disable that behavior.
+* `nonull` Set to never return an empty set, instead returning a set
+ containing the pattern itself. This is the default in glob(3).
+* `nocase` Perform a case-insensitive match. Note that case-insensitive
+ filesystems will sometimes result in glob returning results that are
+ case-insensitively matched anyway, since readdir and stat will not
+ raise an error.
+* `debug` Set to enable debug logging in minimatch and glob.
+* `globDebug` Set to enable debug logging in glob, but not minimatch.
+
+## Comparisons to other fnmatch/glob implementations
+
+While strict compliance with the existing standards is a worthwhile
+goal, some discrepancies exist between node-glob and other
+implementations, and are intentional.
+
+If the pattern starts with a `!` character, then it is negated. Set the
+`nonegate` flag to suppress this behavior, and treat leading `!`
+characters normally. This is perhaps relevant if you wish to start the
+pattern with a negative extglob pattern like `!(a|B)`. Multiple `!`
+characters at the start of a pattern will negate the pattern multiple
+times.
+
+If a pattern starts with `#`, then it is treated as a comment, and
+will not match anything. Use `\#` to match a literal `#` at the
+start of a line, or set the `nocomment` flag to suppress this behavior.
+
+The double-star character `**` is supported by default, unless the
+`noglobstar` flag is set. This is supported in the manner of bsdglob
+and bash 4.1, where `**` only has special significance if it is the only
+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 `nonull` flag is set,
+then glob returns the pattern as-provided, rather than
+interpreting the character escapes. For example,
+`glob.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than
+`"*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
+`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded
+**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are
+checked for validity. Since those two are valid, matching proceeds.
+
+## Windows
+
+**Please only use forward-slashes in glob expressions.**
+
+Though windows uses either `/` or `\` as its path separator, only `/`
+characters are used by this glob implementation. You must use
+forward-slashes **only** in glob expressions. Back-slashes will always
+be interpreted as escape characters, not path separators.
+
+Results from absolute patterns such as `/foo/*` are mounted onto the
+root setting using `path.join`. On windows, this will by default result
+in `/foo/*` matching `C:\foo\bar.txt`.
+
+## Race Conditions
+
+Glob searching, by its very nature, is susceptible to race conditions,
+since it relies on directory walking and such.
+
+As a result, it is possible that a file that exists when glob looks for
+it may have been deleted or modified by the time it returns the result.
+
+As part of its internal implementation, this program caches all stat
+and readdir calls that it makes, in order to cut down on system
+overhead. However, this also makes it even more susceptible to races,
+especially if the statCache object is reused between glob calls.
+
+Users are thus advised not to use a glob result as a
+guarantee of filesystem state in the face of rapid changes.
+For the vast majority of operations, this is never a problem.
diff --git a/node_modules/glob/examples/g.js b/node_modules/glob/examples/g.js
new file mode 100644
index 000000000..be122df00
--- /dev/null
+++ b/node_modules/glob/examples/g.js
@@ -0,0 +1,9 @@
+var Glob = require("../").Glob
+
+var pattern = "test/a/**/[cg]/../[cg]"
+console.log(pattern)
+
+var mg = new Glob(pattern, {mark: true, sync:true}, function (er, matches) {
+ console.log("matches", matches)
+})
+console.log("after")
diff --git a/node_modules/glob/examples/usr-local.js b/node_modules/glob/examples/usr-local.js
new file mode 100644
index 000000000..327a425e4
--- /dev/null
+++ b/node_modules/glob/examples/usr-local.js
@@ -0,0 +1,9 @@
+var Glob = require("../").Glob
+
+var pattern = "{./*/*,/*,/usr/local/*}"
+console.log(pattern)
+
+var mg = new Glob(pattern, {mark: true}, function (er, matches) {
+ console.log("matches", matches)
+})
+console.log("after")
diff --git a/node_modules/glob/glob.js b/node_modules/glob/glob.js
new file mode 100644
index 000000000..aba4ef678
--- /dev/null
+++ b/node_modules/glob/glob.js
@@ -0,0 +1,601 @@
+// Approach:
+//
+// 1. Get the minimatch set
+// 2. For each pattern in the set, PROCESS(pattern)
+// 3. Store matches per-set, then uniq them
+//
+// PROCESS(pattern)
+// Get the first [n] items from pattern that are all strings
+// Join these together. This is PREFIX.
+// If there is no more remaining, then stat(PREFIX) and
+// add to matches if it succeeds. END.
+// readdir(PREFIX) as ENTRIES
+// If fails, END
+// If pattern[n] is GLOBSTAR
+// // handle the case where the globstar match is empty
+// // by pruning it out, and testing the resulting pattern
+// PROCESS(pattern[0..n] + pattern[n+1 .. $])
+// // handle other cases.
+// for ENTRY in ENTRIES (not dotfiles)
+// // attach globstar + tail onto the entry
+// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $])
+//
+// else // not globstar
+// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot)
+// Test ENTRY against pattern[n+1]
+// If fails, continue
+// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $])
+//
+// Caveat:
+// Cache all stats and readdirs results to minimize syscall. Since all
+// we ever care about is existence and directory-ness, we can just keep
+// `true` for files, and [children,...] for directories, or `false` for
+// things that don't exist.
+
+
+
+module.exports = glob
+
+var fs = require("graceful-fs")
+, minimatch = require("minimatch")
+, Minimatch = minimatch.Minimatch
+, inherits = require("inherits")
+, EE = require("events").EventEmitter
+, path = require("path")
+, isDir = {}
+, assert = require("assert").ok
+, EOF = {}
+
+function glob (pattern, options, cb) {
+ if (typeof options === "function") cb = options, options = {}
+ if (!options) options = {}
+
+ if (typeof options === "number") {
+ deprecated()
+ return
+ }
+
+ var g = new Glob(pattern, options, cb)
+ return g.sync ? g.found : g
+}
+
+glob.fnmatch = deprecated
+
+function deprecated () {
+ throw new Error("glob's interface has changed. Please see the docs.")
+}
+
+glob.sync = globSync
+function globSync (pattern, options) {
+ if (typeof options === "number") {
+ deprecated()
+ return
+ }
+
+ options = options || {}
+ options.sync = true
+ return glob(pattern, options)
+}
+
+
+glob.Glob = Glob
+inherits(Glob, EE)
+function Glob (pattern, options, cb) {
+ if (!(this instanceof Glob)) {
+ return new Glob(pattern, options, cb)
+ }
+
+ if (typeof cb === "function") {
+ this.on("error", cb)
+ this.on("end", function (matches) {
+ // console.error("cb with matches", matches)
+ cb(null, matches)
+ })
+ }
+
+ options = options || {}
+
+ this.maxDepth = options.maxDepth || 1000
+ this.maxLength = options.maxLength || Infinity
+ this.statCache = options.statCache || {}
+
+ this.changedCwd = false
+ var cwd = process.cwd()
+ if (!options.hasOwnProperty("cwd")) this.cwd = cwd
+ else {
+ this.cwd = options.cwd
+ this.changedCwd = path.resolve(options.cwd) !== cwd
+ }
+
+ this.root = options.root || path.resolve(this.cwd, "/")
+ this.root = path.resolve(this.root)
+
+ this.nomount = !!options.nomount
+
+ if (!pattern) {
+ throw new Error("must provide pattern")
+ }
+
+ // base-matching: just use globstar for that.
+ if (options.matchBase && -1 === pattern.indexOf("/")) {
+ if (options.noglobstar) {
+ throw new Error("base matching requires globstar")
+ }
+ pattern = "**/" + pattern
+ }
+
+ this.dot = !!options.dot
+ this.mark = !!options.mark
+ this.sync = !!options.sync
+ this.nounique = !!options.nounique
+ this.nonull = !!options.nonull
+ this.nosort = !!options.nosort
+ this.nocase = !!options.nocase
+ this.stat = !!options.stat
+ this.debug = !!options.debug || !!options.globDebug
+ this.silent = !!options.silent
+
+ var mm = this.minimatch = new Minimatch(pattern, options)
+ this.options = mm.options
+ pattern = this.pattern = mm.pattern
+
+ this.error = null
+ this.aborted = false
+
+ EE.call(this)
+
+ // process each pattern in the minimatch set
+ var n = this.minimatch.set.length
+
+ // The matches are stored as {<filename>: true,...} so that
+ // duplicates are automagically pruned.
+ // Later, we do an Object.keys() on these.
+ // Keep them as a list so we can fill in when nonull is set.
+ this.matches = new Array(n)
+
+ this.minimatch.set.forEach(iterator.bind(this))
+ function iterator (pattern, i, set) {
+ this._process(pattern, 0, i, function (er) {
+ if (er) this.emit("error", er)
+ if (-- n <= 0) this._finish()
+ })
+ }
+}
+
+Glob.prototype._finish = function () {
+ assert(this instanceof Glob)
+
+ var nou = this.nounique
+ , all = nou ? [] : {}
+
+ for (var i = 0, l = this.matches.length; i < l; i ++) {
+ var matches = this.matches[i]
+ if (this.debug) console.error("matches[%d] =", i, matches)
+ // do like the shell, and spit out the literal glob
+ if (!matches) {
+ if (this.nonull) {
+ var literal = this.minimatch.globSet[i]
+ if (nou) all.push(literal)
+ else nou[literal] = true
+ }
+ } else {
+ // had matches
+ var m = Object.keys(matches)
+ if (nou) all.push.apply(all, m)
+ else m.forEach(function (m) {
+ all[m] = true
+ })
+ }
+ }
+
+ if (!nou) all = Object.keys(all)
+
+ if (!this.nosort) {
+ all = all.sort(this.nocase ? alphasorti : alphasort)
+ }
+
+ if (this.mark) {
+ // at *some* point we statted all of these
+ all = all.map(function (m) {
+ var sc = this.statCache[m]
+ if (!sc) return m
+ if (m.slice(-1) !== "/" && (Array.isArray(sc) || sc === 2)) {
+ return m + "/"
+ }
+ if (m.slice(-1) === "/") {
+ return m.replace(/\/$/, "")
+ }
+ return m
+ })
+ }
+
+ if (this.debug) console.error("emitting end", all)
+
+ EOF = this.found = all
+ this.emitMatch(EOF)
+}
+
+function alphasorti (a, b) {
+ a = a.toLowerCase()
+ b = b.toLowerCase()
+ return alphasort(a, b)
+}
+
+function alphasort (a, b) {
+ return a > b ? 1 : a < b ? -1 : 0
+}
+
+Glob.prototype.abort = function () {
+ this.aborted = true
+ this.emit("abort")
+}
+
+Glob.prototype.pause = function () {
+ if (this.paused) return
+ if (this.sync)
+ this.emit("error", new Error("Can't pause/resume sync glob"))
+ this.paused = true
+ this.emit("pause")
+}
+
+Glob.prototype.resume = function () {
+ if (!this.paused) return
+ if (this.sync)
+ this.emit("error", new Error("Can't pause/resume sync glob"))
+ this.paused = false
+ this.emit("resume")
+}
+
+
+Glob.prototype.emitMatch = function (m) {
+ if (!this.paused) {
+ this.emit(m === EOF ? "end" : "match", m)
+ return
+ }
+
+ if (!this._emitQueue) {
+ this._emitQueue = []
+ this.once("resume", function () {
+ var q = this._emitQueue
+ this._emitQueue = null
+ q.forEach(function (m) {
+ this.emitMatch(m)
+ }, this)
+ })
+ }
+
+ this._emitQueue.push(m)
+
+ //this.once("resume", this.emitMatch.bind(this, m))
+}
+
+
+
+Glob.prototype._process = function (pattern, depth, index, cb_) {
+ assert(this instanceof Glob)
+
+ var cb = function cb (er, res) {
+ assert(this instanceof Glob)
+ if (this.paused) {
+ if (!this._processQueue) {
+ this._processQueue = []
+ this.once("resume", function () {
+ var q = this._processQueue
+ this._processQueue = null
+ q.forEach(function (cb) { cb() })
+ })
+ }
+ this._processQueue.push(cb_.bind(this, er, res))
+ } else {
+ cb_.call(this, er, res)
+ }
+ }.bind(this)
+
+ if (this.aborted) return cb()
+
+ if (depth > this.maxDepth) return cb()
+
+ // Get the first [n] parts of pattern that are all strings.
+ var n = 0
+ while (typeof pattern[n] === "string") {
+ n ++
+ }
+ // now n is the index of the first one that is *not* a string.
+
+ // see if there's anything else
+ var prefix
+ switch (n) {
+ // if not, then this is rather simple
+ case pattern.length:
+ prefix = pattern.join("/")
+ this._stat(prefix, function (exists, isDir) {
+ // either it's there, or it isn't.
+ // nothing more to do, either way.
+ if (exists) {
+ if (prefix.charAt(0) === "/" && !this.nomount) {
+ prefix = path.join(this.root, prefix)
+ }
+ this.matches[index] = this.matches[index] || {}
+ this.matches[index][prefix] = true
+ this.emitMatch(prefix)
+ }
+ return cb()
+ })
+ return
+
+ case 0:
+ // pattern *starts* with some non-trivial item.
+ // going to readdir(cwd), but not include the prefix in matches.
+ prefix = null
+ break
+
+ default:
+ // pattern has some string bits in the front.
+ // whatever it starts with, whether that's "absolute" like /foo/bar,
+ // or "relative" like "../baz"
+ prefix = pattern.slice(0, n)
+ prefix = prefix.join("/")
+ break
+ }
+
+ // get the list of entries.
+ var read
+ if (prefix === null) read = "."
+ else if (isAbsolute(prefix)) {
+ read = prefix = path.join("/", prefix)
+ if (this.debug) console.error('absolute: ', prefix, this.root, pattern)
+ } else read = prefix
+
+ if (this.debug) console.error('readdir(%j)', read, this.cwd, this.root)
+ return this._readdir(read, function (er, entries) {
+ if (er) {
+ // not a directory!
+ // this means that, whatever else comes after this, it can never match
+ return cb()
+ }
+
+ // globstar is special
+ if (pattern[n] === minimatch.GLOBSTAR) {
+ // test without the globstar, and with every child both below
+ // and replacing the globstar.
+ var s = [ pattern.slice(0, n).concat(pattern.slice(n + 1)) ]
+ entries.forEach(function (e) {
+ if (e.charAt(0) === "." && !this.dot) return
+ // instead of the globstar
+ s.push(pattern.slice(0, n).concat(e).concat(pattern.slice(n + 1)))
+ // below the globstar
+ s.push(pattern.slice(0, n).concat(e).concat(pattern.slice(n)))
+ }, this)
+
+ // now asyncForEach over this
+ var l = s.length
+ , errState = null
+ s.forEach(function (gsPattern) {
+ this._process(gsPattern, depth + 1, index, function (er) {
+ if (errState) return
+ if (er) return cb(errState = er)
+ if (--l <= 0) return cb()
+ })
+ }, this)
+
+ return
+ }
+
+ // not a globstar
+ // It will only match dot entries if it starts with a dot, or if
+ // dot is set. Stuff like @(.foo|.bar) isn't allowed.
+ var pn = pattern[n]
+ if (typeof pn === "string") {
+ var found = entries.indexOf(pn) !== -1
+ entries = found ? entries[pn] : []
+ } else {
+ var rawGlob = pattern[n]._glob
+ , dotOk = this.dot || rawGlob.charAt(0) === "."
+
+ entries = entries.filter(function (e) {
+ return (e.charAt(0) !== "." || dotOk) &&
+ (typeof pattern[n] === "string" && e === pattern[n] ||
+ e.match(pattern[n]))
+ })
+ }
+
+ // If n === pattern.length - 1, then there's no need for the extra stat
+ // *unless* the user has specified "mark" or "stat" explicitly.
+ // We know that they exist, since the readdir returned them.
+ if (n === pattern.length - 1 &&
+ !this.mark &&
+ !this.stat) {
+ entries.forEach(function (e) {
+ if (prefix) {
+ if (prefix !== "/") e = prefix + "/" + e
+ else e = prefix + e
+ }
+ if (e.charAt(0) === "/" && !this.nomount) {
+ e = path.join(this.root, e)
+ }
+
+ this.matches[index] = this.matches[index] || {}
+ this.matches[index][e] = true
+ this.emitMatch(e)
+ }, this)
+ return cb.call(this)
+ }
+
+
+ // now test all the remaining entries as stand-ins for that part
+ // of the pattern.
+ var l = entries.length
+ , errState = null
+ if (l === 0) return cb() // no matches possible
+ entries.forEach(function (e) {
+ var p = pattern.slice(0, n).concat(e).concat(pattern.slice(n + 1))
+ this._process(p, depth + 1, index, function (er) {
+ if (errState) return
+ if (er) return cb(errState = er)
+ if (--l === 0) return cb.call(this)
+ })
+ }, this)
+ })
+
+}
+
+Glob.prototype._stat = function (f, cb) {
+ assert(this instanceof Glob)
+ var abs = f
+ if (f.charAt(0) === "/") {
+ abs = path.join(this.root, f)
+ } else if (this.changedCwd) {
+ abs = path.resolve(this.cwd, f)
+ }
+ if (this.debug) console.error('stat', [this.cwd, f, '=', abs])
+ if (f.length > this.maxLength) {
+ var er = new Error("Path name too long")
+ er.code = "ENAMETOOLONG"
+ er.path = f
+ return this._afterStat(f, abs, cb, er)
+ }
+
+ if (this.statCache.hasOwnProperty(f)) {
+ var exists = this.statCache[f]
+ , isDir = exists && (Array.isArray(exists) || exists === 2)
+ if (this.sync) return cb.call(this, !!exists, isDir)
+ return process.nextTick(cb.bind(this, !!exists, isDir))
+ }
+
+ if (this.sync) {
+ var er, stat
+ try {
+ stat = fs.statSync(abs)
+ } catch (e) {
+ er = e
+ }
+ this._afterStat(f, abs, cb, er, stat)
+ } else {
+ fs.stat(abs, this._afterStat.bind(this, f, abs, cb))
+ }
+}
+
+Glob.prototype._afterStat = function (f, abs, cb, er, stat) {
+ var exists
+ assert(this instanceof Glob)
+ if (er || !stat) {
+ exists = false
+ } else {
+ exists = stat.isDirectory() ? 2 : 1
+ }
+ this.statCache[f] = this.statCache[f] || exists
+ cb.call(this, !!exists, exists === 2)
+}
+
+Glob.prototype._readdir = function (f, cb) {
+ assert(this instanceof Glob)
+ var abs = f
+ if (f.charAt(0) === "/") {
+ abs = path.join(this.root, f)
+ } else if (isAbsolute(f)) {
+ abs = f
+ } else if (this.changedCwd) {
+ abs = path.resolve(this.cwd, f)
+ }
+
+ if (this.debug) console.error('readdir', [this.cwd, f, abs])
+ if (f.length > this.maxLength) {
+ var er = new Error("Path name too long")
+ er.code = "ENAMETOOLONG"
+ er.path = f
+ return this._afterReaddir(f, abs, cb, er)
+ }
+
+ if (this.statCache.hasOwnProperty(f)) {
+ var c = this.statCache[f]
+ if (Array.isArray(c)) {
+ if (this.sync) return cb.call(this, null, c)
+ return process.nextTick(cb.bind(this, null, c))
+ }
+
+ if (!c || c === 1) {
+ // either ENOENT or ENOTDIR
+ var code = c ? "ENOTDIR" : "ENOENT"
+ , er = new Error((c ? "Not a directory" : "Not found") + ": " + f)
+ er.path = f
+ er.code = code
+ if (this.debug) console.error(f, er)
+ if (this.sync) return cb.call(this, er)
+ return process.nextTick(cb.bind(this, er))
+ }
+
+ // at this point, c === 2, meaning it's a dir, but we haven't
+ // had to read it yet, or c === true, meaning it's *something*
+ // but we don't have any idea what. Need to read it, either way.
+ }
+
+ if (this.sync) {
+ var er, entries
+ try {
+ entries = fs.readdirSync(abs)
+ } catch (e) {
+ er = e
+ }
+ return this._afterReaddir(f, abs, cb, er, entries)
+ }
+
+ fs.readdir(abs, this._afterReaddir.bind(this, f, abs, cb))
+}
+
+Glob.prototype._afterReaddir = function (f, abs, cb, er, entries) {
+ assert(this instanceof Glob)
+ if (entries && !er) {
+ this.statCache[f] = entries
+ // if we haven't asked to stat everything for suresies, then just
+ // assume that everything in there exists, so we can avoid
+ // having to stat it a second time. This also gets us one step
+ // further into ELOOP territory.
+ if (!this.mark && !this.stat) {
+ entries.forEach(function (e) {
+ if (f === "/") e = f + e
+ else e = f + "/" + e
+ this.statCache[e] = true
+ }, this)
+ }
+
+ return cb.call(this, er, entries)
+ }
+
+ // now handle errors, and cache the information
+ if (er) switch (er.code) {
+ case "ENOTDIR": // totally normal. means it *does* exist.
+ this.statCache[f] = 1
+ return cb.call(this, er)
+ case "ENOENT": // not terribly unusual
+ case "ELOOP":
+ case "ENAMETOOLONG":
+ case "UNKNOWN":
+ this.statCache[f] = false
+ return cb.call(this, er)
+ default: // some unusual error. Treat as failure.
+ this.statCache[f] = false
+ if (this.strict) this.emit("error", er)
+ if (!this.silent) console.error("glob error", er)
+ return cb.call(this, er)
+ }
+}
+
+var isAbsolute = process.platform === "win32" ? absWin : absUnix
+
+function absWin (p) {
+ if (absUnix(p)) return true
+ // pull off the device/UNC bit from a windows path.
+ // from node's lib/path.js
+ var splitDeviceRe =
+ /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?([\\\/])?/
+ , result = splitDeviceRe.exec(p)
+ , device = result[1] || ''
+ , isUnc = device && device.charAt(1) !== ':'
+ , isAbsolute = !!result[2] || isUnc // UNC paths are always absolute
+
+ return isAbsolute
+}
+
+function absUnix (p) {
+ return p.charAt(0) === "/" || p === ""
+}
diff --git a/node_modules/glob/package.json b/node_modules/glob/package.json
new file mode 100644
index 000000000..06de582ae
--- /dev/null
+++ b/node_modules/glob/package.json
@@ -0,0 +1,38 @@
+{
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me/"
+ },
+ "name": "glob",
+ "description": "a little globber",
+ "version": "3.1.9",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/isaacs/node-glob.git"
+ },
+ "main": "glob.js",
+ "engines": {
+ "node": "*"
+ },
+ "dependencies": {
+ "minimatch": "0.2",
+ "graceful-fs": "~1.1.2",
+ "inherits": "1"
+ },
+ "devDependencies": {
+ "tap": "~0.2.3",
+ "mkdirp": "0",
+ "rimraf": "1"
+ },
+ "scripts": {
+ "test": "tap test/*.js"
+ },
+ "license": "BSD",
+ "readme": "# Glob\n\nThis is a glob implementation in JavaScript. It uses the `minimatch`\nlibrary to do its matching.\n\n## Attention: node-glob users!\n\nThe API has changed dramatically between 2.x and 3.x. This library is\nnow 100% JavaScript, and the integer flags have been replaced with an\noptions object.\n\nAlso, there's an event emitter class, proper tests, and all the other\nthings you've come to expect from node modules.\n\nAnd best of all, no compilation!\n\n## Usage\n\n```javascript\nvar glob = require(\"glob\")\n\n// options is optional\nglob(\"**/*.js\", options, function (er, files) {\n // files is an array of filenames.\n // If the `nonull` option is set, and nothing\n // was found, then files is [\"**/*.js\"]\n // er is an error object or null.\n})\n```\n\n## Features\n\nPlease see the [minimatch\ndocumentation](https://github.com/isaacs/minimatch) for more details.\n\nSupports these glob features:\n\n* Brace Expansion\n* Extended glob matching\n* \"Globstar\" `**` matching\n\nSee:\n\n* `man sh`\n* `man bash`\n* `man 3 fnmatch`\n* `man 5 gitignore`\n* [minimatch documentation](https://github.com/isaacs/minimatch)\n\n## glob(pattern, [options], cb)\n\n* `pattern` {String} Pattern to be matched\n* `options` {Object}\n* `cb` {Function}\n * `err` {Error | null}\n * `matches` {Array<String>} filenames found matching the pattern\n\nPerform an asynchronous glob search.\n\n## glob.sync(pattern, [options]\n\n* `pattern` {String} Pattern to be matched\n* `options` {Object}\n* return: {Array<String>} filenames found matching the pattern\n\nPerform a synchronous glob search.\n\n## Class: glob.Glob\n\nCreate a Glob object by instanting the `glob.Glob` class.\n\n```javascript\nvar Glob = require(\"glob\").Glob\nvar mg = new Glob(pattern, options, cb)\n```\n\nIt's an EventEmitter, and starts walking the filesystem to find matches\nimmediately.\n\n### new glob.Glob(pattern, [options], [cb])\n\n* `pattern` {String} pattern to search for\n* `options` {Object}\n* `cb` {Function} Called when an error occurs, or matches are found\n * `err` {Error | null}\n * `matches` {Array<String>} filenames found matching the pattern\n\nNote that if the `sync` flag is set in the options, then matches will\nbe immediately available on the `g.found` member.\n\n### Properties\n\n* `minimatch` The minimatch object that the glob uses.\n* `options` The options object passed in.\n* `error` The error encountered. When an error is encountered, the\n glob object is in an undefined state, and should be discarded.\n* `aborted` Boolean which is set to true when calling `abort()`. There\n is no way at this time to continue a glob search after aborting, but\n you can re-use the statCache to avoid having to duplicate syscalls.\n\n### Events\n\n* `end` When the matching is finished, this is emitted with all the\n matches found. If the `nonull` option is set, and no match was found,\n then the `matches` list contains the original pattern. The matches\n are sorted, unless the `nosort` flag is set.\n* `match` Every time a match is found, this is emitted with the matched.\n* `error` Emitted when an unexpected error is encountered, or whenever\n any fs error occurs if `options.strict` is set.\n* `abort` When `abort()` is called, this event is raised.\n\n### Methods\n\n* `abort` Stop the search.\n\n### Options\n\nAll the options that can be passed to Minimatch can also be passed to\nGlob to change pattern matching behavior. Also, some have been added,\nor have glob-specific ramifications.\n\nAll options are false by default, unless otherwise noted.\n\nAll options are added to the glob object, as well.\n\n* `cwd` The current working directory in which to search. Defaults\n to `process.cwd()`.\n* `root` The place where patterns starting with `/` will be mounted\n onto. Defaults to `path.resolve(options.cwd, \"/\")` (`/` on Unix\n systems, and `C:\\` or some such on Windows.)\n* `nomount` By default, a pattern starting with a forward-slash will be\n \"mounted\" onto the root setting, so that a valid filesystem path is\n returned. Set this flag to disable that behavior.\n* `mark` Add a `/` character to directory matches. Note that this\n requires additional stat calls.\n* `nosort` Don't sort the results.\n* `stat` Set to true to stat *all* results. This reduces performance\n somewhat, and is completely unnecessary, unless `readdir` is presumed\n to be an untrustworthy indicator of file existence. It will cause\n ELOOP to be triggered one level sooner in the case of cyclical\n symbolic links.\n* `silent` When an unusual error is encountered\n when attempting to read a directory, a warning will be printed to\n stderr. Set the `silent` option to true to suppress these warnings.\n* `strict` When an unusual error is encountered\n when attempting to read a directory, the process will just continue on\n in search of other matches. Set the `strict` option to raise an error\n in these cases.\n* `statCache` A cache of results of filesystem information, to prevent\n unnecessary stat calls. While it should not normally be necessary to\n set this, you may pass the statCache from one glob() call to the\n options object of another, if you know that the filesystem will not\n change between calls. (See \"Race Conditions\" below.)\n* `sync` Perform a synchronous glob search.\n* `nounique` In some cases, brace-expanded patterns can result in the\n same file showing up multiple times in the result set. By default,\n this implementation prevents duplicates in the result set.\n Set this flag to disable that behavior.\n* `nonull` Set to never return an empty set, instead returning a set\n containing the pattern itself. This is the default in glob(3).\n* `nocase` Perform a case-insensitive match. Note that case-insensitive\n filesystems will sometimes result in glob returning results that are\n case-insensitively matched anyway, since readdir and stat will not\n raise an error.\n* `debug` Set to enable debug logging in minimatch and glob.\n* `globDebug` Set to enable debug logging in glob, but not minimatch.\n\n## Comparisons to other fnmatch/glob implementations\n\nWhile strict compliance with the existing standards is a worthwhile\ngoal, some discrepancies exist between node-glob and other\nimplementations, and are intentional.\n\nIf the pattern starts with a `!` character, then it is negated. Set the\n`nonegate` flag to suppress this behavior, and treat leading `!`\ncharacters normally. This is perhaps relevant if you wish to start the\npattern with a negative extglob pattern like `!(a|B)`. Multiple `!`\ncharacters at the start of a pattern will negate the pattern multiple\ntimes.\n\nIf a pattern starts with `#`, then it is treated as a comment, and\nwill not match anything. Use `\\#` to match a literal `#` at the\nstart of a line, or set the `nocomment` flag to suppress this behavior.\n\nThe double-star character `**` is supported by default, unless the\n`noglobstar` flag is set. This is supported in the manner of bsdglob\nand bash 4.1, where `**` only has special significance if it is the only\nthing in a path part. That is, `a/**/b` will match `a/x/y/b`, but\n`a/**b` will not. **Note that this is different from the way that `**` is\nhandled by ruby's `Dir` class.**\n\nIf an escaped pattern has no matches, and the `nonull` flag is set,\nthen glob returns the pattern as-provided, rather than\ninterpreting the character escapes. For example,\n`glob.match([], \"\\\\*a\\\\?\")` will return `\"\\\\*a\\\\?\"` rather than\n`\"*a?\"`. This is akin to setting the `nullglob` option in bash, except\nthat it does not resolve escaped pattern characters.\n\nIf brace expansion is not disabled, then it is performed before any\nother interpretation of the glob pattern. Thus, a pattern like\n`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded\n**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are\nchecked for validity. Since those two are valid, matching proceeds.\n\n## Windows\n\n**Please only use forward-slashes in glob expressions.**\n\nThough windows uses either `/` or `\\` as its path separator, only `/`\ncharacters are used by this glob implementation. You must use\nforward-slashes **only** in glob expressions. Back-slashes will always\nbe interpreted as escape characters, not path separators.\n\nResults from absolute patterns such as `/foo/*` are mounted onto the\nroot setting using `path.join`. On windows, this will by default result\nin `/foo/*` matching `C:\\foo\\bar.txt`.\n\n## Race Conditions\n\nGlob searching, by its very nature, is susceptible to race conditions,\nsince it relies on directory walking and such.\n\nAs a result, it is possible that a file that exists when glob looks for\nit may have been deleted or modified by the time it returns the result.\n\nAs part of its internal implementation, this program caches all stat\nand readdir calls that it makes, in order to cut down on system\noverhead. However, this also makes it even more susceptible to races,\nespecially if the statCache object is reused between glob calls.\n\nUsers are thus advised not to use a glob result as a\nguarantee of filesystem state in the face of rapid changes.\nFor the vast majority of operations, this is never a problem.\n",
+ "_id": "glob@3.1.9",
+ "dist": {
+ "shasum": "a81b5dd6244b74b277cc1e825f25ebc511854525"
+ },
+ "_from": "glob"
+}
diff --git a/node_modules/glob/test/00-setup.js b/node_modules/glob/test/00-setup.js
new file mode 100644
index 000000000..2b606432a
--- /dev/null
+++ b/node_modules/glob/test/00-setup.js
@@ -0,0 +1,61 @@
+// just a little pre-run script to set up the fixtures.
+// zz-finish cleans it up
+
+var mkdirp = require("mkdirp")
+var path = require("path")
+var i = 0
+var tap = require("tap")
+var fs = require("fs")
+var rimraf = require("rimraf")
+
+var files =
+[ "a/.abcdef/x/y/z/a"
+, "a/abcdef/g/h"
+, "a/abcfed/g/h"
+, "a/b/c/d"
+, "a/bc/e/f"
+, "a/c/d/c/b"
+, "a/cb/e/f"
+]
+
+var symlinkTo = path.resolve(__dirname, "a/symlink/a/b/c")
+var symlinkFrom = "../.."
+
+files = files.map(function (f) {
+ return path.resolve(__dirname, f)
+})
+
+tap.test("remove fixtures", function (t) {
+ rimraf(path.resolve(__dirname, "a"), function (er) {
+ t.ifError(er, "remove fixtures")
+ t.end()
+ })
+})
+
+files.forEach(function (f) {
+ tap.test(f, function (t) {
+ var d = path.dirname(f)
+ mkdirp(d, 0755, function (er) {
+ if (er) {
+ t.fail(er)
+ return t.bailout()
+ }
+ fs.writeFile(f, "i like tests", function (er) {
+ t.ifError(er, "make file")
+ t.end()
+ })
+ })
+ })
+})
+
+tap.test("symlinky", function (t) {
+ var d = path.dirname(symlinkTo)
+ console.error("mkdirp", d)
+ mkdirp(d, 0755, function (er) {
+ t.ifError(er)
+ fs.symlink(symlinkFrom, symlinkTo, function (er) {
+ t.ifError(er, "make symlink")
+ t.end()
+ })
+ })
+})
diff --git a/node_modules/glob/test/bash-comparison.js b/node_modules/glob/test/bash-comparison.js
new file mode 100644
index 000000000..fbadc314c
--- /dev/null
+++ b/node_modules/glob/test/bash-comparison.js
@@ -0,0 +1,119 @@
+// basic test
+// show that it does the same thing by default as the shell.
+var tap = require("tap")
+, child_process = require("child_process")
+
+// put more patterns here.
+, globs =
+ [
+ "test/a/*/+(c|g)/./d"
+ ,"test/a/**/[cg]/../[cg]"
+ ,"test/a/{b,c,d,e,f}/**/g"
+ ,"test/a/b/**"
+ ,"test/**/g"
+ ,"test/a/abc{fed,def}/g/h"
+ ,"test/a/abc{fed/g,def}/**/"
+ ,"test/a/abc{fed/g,def}/**///**/"
+ ,"test/**/a/**/"
+ ,"test/+(a|b|c)/a{/,bc*}/**"
+ ,"test/*/*/*/f"
+ ,"test/**/f"
+ ,"test/a/symlink/a/b/c/a/b/c/a/b/c//a/b/c////a/b/c/**/b/c/**"
+ ,"{./*/*,/usr/local/*}"
+ ,"{/*,*}" // evil owl face! how you taunt me!
+ ]
+, glob = require("../")
+, path = require("path")
+
+// run from the root of the project
+// this is usually where you're at anyway, but be sure.
+process.chdir(path.resolve(__dirname, ".."))
+
+function alphasort (a, b) {
+ a = a.toLowerCase()
+ b = b.toLowerCase()
+ return a > b ? 1 : a < b ? -1 : 0
+}
+
+globs.forEach(function (pattern) {
+ var echoOutput
+ tap.test(pattern, function (t) {
+ var bashPattern = pattern
+ , cmd = "shopt -s globstar && " +
+ "shopt -s extglob && " +
+ "shopt -s nullglob && " +
+ // "shopt >&2; " +
+ "eval \'for i in " + bashPattern + "; do echo $i; done\'"
+ , cp = child_process.spawn("bash", ["-c",cmd])
+ , out = []
+ , globResult
+ cp.stdout.on("data", function (c) {
+ out.push(c)
+ })
+ cp.stderr.on("data", function (c) {
+ process.stderr.write(c)
+ })
+ cp.stdout.on("close", function () {
+ echoOutput = flatten(out)
+ if (!echoOutput) echoOutput = []
+ else {
+ echoOutput = echoOutput.split(/\r*\n/).map(function (m) {
+ // Bash is a oddly inconsistent with slashes in the
+ // the results. This implementation is a bit more
+ // normalized. Account for this in the test results.
+ return m.replace(/\/+/g, "/").replace(/\/$/, "")
+ }).sort(alphasort).reduce(function (set, f) {
+ if (f !== set[set.length - 1]) set.push(f)
+ return set
+ }, []).sort(alphasort)
+ }
+ next()
+ })
+
+ glob(pattern, function (er, matches) {
+ // sort and unpark, just to match the shell results
+ matches = matches.map(function (m) {
+ return m.replace(/\/+/g, "/").replace(/\/$/, "")
+ }).sort(alphasort).reduce(function (set, f) {
+ if (f !== set[set.length - 1]) set.push(f)
+ return set
+ }, []).sort(alphasort)
+
+ t.ifError(er, pattern + " should not error")
+ globResult = matches
+ next()
+ })
+
+ function next () {
+ if (!echoOutput || !globResult) return
+
+ t.deepEqual(globResult, echoOutput, "should match shell")
+ t.end()
+ }
+ })
+
+ tap.test(pattern + " sync", function (t) {
+ var matches = glob.sync(pattern).map(function (m) {
+ return m.replace(/\/+/g, "/").replace(/\/$/, "")
+ }).sort(alphasort).reduce(function (set, f) {
+ if (f !== set[set.length - 1]) set.push(f)
+ return set
+ }, []).sort(alphasort)
+
+ t.deepEqual(matches, echoOutput, "should match shell")
+ t.end()
+ })
+})
+
+function flatten (chunks) {
+ var s = 0
+ chunks.forEach(function (c) { s += c.length })
+ var out = new Buffer(s)
+ s = 0
+ chunks.forEach(function (c) {
+ c.copy(out, s)
+ s += c.length
+ })
+
+ return out.toString().trim()
+}
diff --git a/node_modules/glob/test/cwd-test.js b/node_modules/glob/test/cwd-test.js
new file mode 100644
index 000000000..352c27efa
--- /dev/null
+++ b/node_modules/glob/test/cwd-test.js
@@ -0,0 +1,55 @@
+var tap = require("tap")
+
+var origCwd = process.cwd()
+process.chdir(__dirname)
+
+tap.test("changing cwd and searching for **/d", function (t) {
+ var glob = require('../')
+ var path = require('path')
+ t.test('.', function (t) {
+ glob('**/d', function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ 'a/b/c/d', 'a/c/d' ])
+ t.end()
+ })
+ })
+
+ t.test('a', function (t) {
+ glob('**/d', {cwd:path.resolve('a')}, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ 'b/c/d', 'c/d' ])
+ t.end()
+ })
+ })
+
+ t.test('a/b', function (t) {
+ glob('**/d', {cwd:path.resolve('a/b')}, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ 'c/d' ])
+ t.end()
+ })
+ })
+
+ t.test('a/b/', function (t) {
+ glob('**/d', {cwd:path.resolve('a/b/')}, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ 'c/d' ])
+ t.end()
+ })
+ })
+
+ t.test('.', function (t) {
+ glob('**/d', {cwd: process.cwd()}, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ 'a/b/c/d', 'a/c/d' ])
+ t.end()
+ })
+ })
+
+ t.test('cd -', function (t) {
+ process.chdir(origCwd)
+ t.end()
+ })
+
+ t.end()
+})
diff --git a/node_modules/glob/test/pause-resume.js b/node_modules/glob/test/pause-resume.js
new file mode 100644
index 000000000..481d1aae4
--- /dev/null
+++ b/node_modules/glob/test/pause-resume.js
@@ -0,0 +1,98 @@
+// show that no match events happen while paused.
+var tap = require("tap")
+, child_process = require("child_process")
+// just some gnarly pattern with lots of matches
+, pattern = "test/a/symlink/a/b/c/a/b/c/a/b/c//a/b/c////a/b/c/**/b/c/**"
+, glob = require("../")
+, Glob = glob.Glob
+, path = require("path")
+
+// run from the root of the project
+// this is usually where you're at anyway, but be sure.
+process.chdir(path.resolve(__dirname, ".."))
+
+function alphasort (a, b) {
+ a = a.toLowerCase()
+ b = b.toLowerCase()
+ return a > b ? 1 : a < b ? -1 : 0
+}
+
+function cleanResults (m) {
+ // normalize discrepancies in ordering, duplication,
+ // and ending slashes.
+ return m.map(function (m) {
+ return m.replace(/\/+/g, "/").replace(/\/$/, "")
+ }).sort(alphasort).reduce(function (set, f) {
+ if (f !== set[set.length - 1]) set.push(f)
+ return set
+ }, []).sort(alphasort)
+}
+
+function flatten (chunks) {
+ var s = 0
+ chunks.forEach(function (c) { s += c.length })
+ var out = new Buffer(s)
+ s = 0
+ chunks.forEach(function (c) {
+ c.copy(out, s)
+ s += c.length
+ })
+
+ return out.toString().trim()
+}
+var bashResults
+tap.test("get bash output", function (t) {
+ var bashPattern = pattern
+ , cmd = "shopt -s globstar && " +
+ "shopt -s extglob && " +
+ "shopt -s nullglob && " +
+ // "shopt >&2; " +
+ "eval \'for i in " + bashPattern + "; do echo $i; done\'"
+ , cp = child_process.spawn("bash", ["-c",cmd])
+ , out = []
+ , globResult
+ cp.stdout.on("data", function (c) {
+ out.push(c)
+ })
+ cp.stderr.on("data", function (c) {
+ process.stderr.write(c)
+ })
+ cp.stdout.on("close", function () {
+ bashResults = flatten(out)
+ if (!bashResults) return t.fail("Didn't get results from bash")
+ else {
+ bashResults = cleanResults(bashResults.split(/\r*\n/))
+ }
+ t.ok(bashResults.length, "got some results")
+ t.end()
+ })
+})
+
+var globResults = []
+tap.test("use a Glob object, and pause/resume it", function (t) {
+ var g = new Glob(pattern)
+ , paused = false
+ , res = []
+
+ g.on("match", function (m) {
+ t.notOk(g.paused, "must not be paused")
+ globResults.push(m)
+ g.pause()
+ t.ok(g.paused, "must be paused")
+ setTimeout(g.resume.bind(g), 1)
+ })
+
+ g.on("end", function (matches) {
+ t.pass("reached glob end")
+ globResults = cleanResults(globResults)
+ matches = cleanResults(matches)
+ t.deepEqual(matches, globResults,
+ "end event matches should be the same as match events")
+
+ t.deepEqual(matches, bashResults,
+ "glob matches should be the same as bash results")
+
+ t.end()
+ })
+})
+
diff --git a/node_modules/glob/test/root-nomount.js b/node_modules/glob/test/root-nomount.js
new file mode 100644
index 000000000..3ac5979b0
--- /dev/null
+++ b/node_modules/glob/test/root-nomount.js
@@ -0,0 +1,39 @@
+var tap = require("tap")
+
+var origCwd = process.cwd()
+process.chdir(__dirname)
+
+tap.test("changing root and searching for /b*/**", function (t) {
+ var glob = require('../')
+ var path = require('path')
+ t.test('.', function (t) {
+ glob('/b*/**', { globDebug: true, root: '.', nomount: true }, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [])
+ t.end()
+ })
+ })
+
+ t.test('a', function (t) {
+ glob('/b*/**', { globDebug: true, root: path.resolve('a'), nomount: true }, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ])
+ t.end()
+ })
+ })
+
+ t.test('root=a, cwd=a/b', function (t) {
+ glob('/b*/**', { globDebug: true, root: 'a', cwd: path.resolve('a/b'), nomount: true }, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ])
+ t.end()
+ })
+ })
+
+ t.test('cd -', function (t) {
+ process.chdir(origCwd)
+ t.end()
+ })
+
+ t.end()
+})
diff --git a/node_modules/glob/test/root.js b/node_modules/glob/test/root.js
new file mode 100644
index 000000000..5ccdd0e94
--- /dev/null
+++ b/node_modules/glob/test/root.js
@@ -0,0 +1,43 @@
+var tap = require("tap")
+
+var origCwd = process.cwd()
+process.chdir(__dirname)
+
+tap.test("changing root and searching for /b*/**", function (t) {
+ var glob = require('../')
+ var path = require('path')
+ t.test('.', function (t) {
+ glob('/b*/**', { globDebug: true, root: '.' }, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [])
+ t.end()
+ })
+ })
+
+ t.test('a', function (t) {
+ glob('/b*/**', { globDebug: true, root: path.resolve('a') }, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ].map(function (m) {
+ return path.join(path.resolve('a'), m)
+ }))
+ t.end()
+ })
+ })
+
+ t.test('root=a, cwd=a/b', function (t) {
+ glob('/b*/**', { globDebug: true, root: 'a', cwd: path.resolve('a/b') }, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ].map(function (m) {
+ return path.join(path.resolve('a'), m)
+ }))
+ t.end()
+ })
+ })
+
+ t.test('cd -', function (t) {
+ process.chdir(origCwd)
+ t.end()
+ })
+
+ t.end()
+})
diff --git a/node_modules/glob/test/zz-cleanup.js b/node_modules/glob/test/zz-cleanup.js
new file mode 100644
index 000000000..e085f0fa7
--- /dev/null
+++ b/node_modules/glob/test/zz-cleanup.js
@@ -0,0 +1,11 @@
+// remove the fixtures
+var tap = require("tap")
+, rimraf = require("rimraf")
+, path = require("path")
+
+tap.test("cleanup fixtures", function (t) {
+ rimraf(path.resolve(__dirname, "a"), function (er) {
+ t.ifError(er, "removed")
+ t.end()
+ })
+})