update glob to v3.1.9

This commit is contained in:
Nathan Rajlich 2012-06-06 14:32:51 -07:00
parent aa8bc9d7cf
commit 41626d9842
5 changed files with 174 additions and 18 deletions

76
node_modules/glob/glob.js generated vendored
View file

@ -44,6 +44,7 @@ var fs = require("graceful-fs")
, path = require("path")
, isDir = {}
, assert = require("assert").ok
, EOF = {}
function glob (pattern, options, cb) {
if (typeof options === "function") cb = options, options = {}
@ -157,7 +158,7 @@ function Glob (pattern, options, cb) {
this._process(pattern, 0, i, function (er) {
if (er) this.emit("error", er)
if (-- n <= 0) this._finish()
}.bind(this))
})
}
}
@ -210,8 +211,8 @@ Glob.prototype._finish = function () {
if (this.debug) console.error("emitting end", all)
this.found = all
this.emit("end", all)
EOF = this.found = all
this.emitMatch(EOF)
}
function alphasorti (a, b) {
@ -229,10 +230,67 @@ Glob.prototype.abort = function () {
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._process = function (pattern, depth, index, cb) {
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)
cb = cb.bind(this)
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()
@ -259,7 +317,7 @@ Glob.prototype._process = function (pattern, depth, index, cb) {
}
this.matches[index] = this.matches[index] || {}
this.matches[index][prefix] = true
this.emit("match", prefix)
this.emitMatch(prefix)
}
return cb()
})
@ -358,7 +416,7 @@ Glob.prototype._process = function (pattern, depth, index, cb) {
this.matches[index] = this.matches[index] || {}
this.matches[index][e] = true
this.emit("match", e)
this.emitMatch(e)
}, this)
return cb.call(this)
}
@ -375,7 +433,7 @@ Glob.prototype._process = function (pattern, depth, index, cb) {
if (errState) return
if (er) return cb(errState = er)
if (--l === 0) return cb.call(this)
}.bind(this))
})
}, this)
})
@ -418,7 +476,7 @@ Glob.prototype._stat = function (f, cb) {
}
Glob.prototype._afterStat = function (f, abs, cb, er, stat) {
var exists;
var exists
assert(this instanceof Glob)
if (er || !stat) {
exists = false