summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/glob/glob.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/glob/glob.js')
-rw-r--r--deps/npm/node_modules/glob/glob.js20
1 files changed, 16 insertions, 4 deletions
diff --git a/deps/npm/node_modules/glob/glob.js b/deps/npm/node_modules/glob/glob.js
index f646c44838..36bbba84cf 100644
--- a/deps/npm/node_modules/glob/glob.js
+++ b/deps/npm/node_modules/glob/glob.js
@@ -36,14 +36,17 @@
module.exports = glob
-var fs = require("fs")
-, minimatch = require("minimatch")
+var fs
+try { fs = require("graceful-fs") } catch (e) { fs = require("fs") }
+
+var minimatch = require("minimatch")
, Minimatch = minimatch.Minimatch
, inherits = require("inherits")
, EE = require("events").EventEmitter
, path = require("path")
, isDir = {}
, assert = require("assert").ok
+, once = require("once")
function glob (pattern, options, cb) {
if (typeof options === "function") cb = options, options = {}
@@ -91,6 +94,7 @@ function Glob (pattern, options, cb) {
}
if (typeof cb === "function") {
+ cb = once(cb)
this.on("error", cb)
this.on("end", function (matches) {
cb(null, matches)
@@ -149,6 +153,10 @@ function Glob (pattern, options, cb) {
this.stat = !!options.stat
this.debug = !!options.debug || !!options.globDebug
+
+ if (/\bglob\b/.test(process.env.NODE_DEBUG || ''))
+ this.debug = true
+
if (this.debug)
this.log = console.error
@@ -176,6 +184,10 @@ function Glob (pattern, options, cb) {
// Keep them as a list so we can fill in when nonull is set.
this.matches = new Array(n)
+ if (this.minimatch.set.length === 0) {
+ return process.nextTick(this._finish.bind(this))
+ }
+
this.minimatch.set.forEach(iterator.bind(this))
function iterator (pattern, i, set) {
this._process(pattern, 0, i, function (er) {
@@ -429,9 +441,9 @@ Glob.prototype._process = function (pattern, depth, index, cb_) {
if (prefix === null) read = "."
else if (isAbsolute(prefix) || isAbsolute(pattern.join("/"))) {
if (!prefix || !isAbsolute(prefix)) {
- prefix = path.join("/", prefix)
+ prefix = "/" + prefix
}
- read = prefix = path.resolve(prefix)
+ read = prefix
// if (process.platform === "win32")
// read = prefix = prefix.replace(/^[a-zA-Z]:|\\/g, "/")