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>2014-02-17 04:03:00 +0400
committerisaacs <i@izs.me>2014-02-17 04:03:00 +0400
commitb20f9bf921a3842fe6392ed94c676b6d06ec253b (patch)
tree36d607d8e685df9da08a46046f54cb1885b89df5 /node_modules/glob
parent62417bc1c91eeed7ba3e7b684026e6620c2df0aa (diff)
glob@3.2.8
Diffstat (limited to 'node_modules/glob')
-rw-r--r--node_modules/glob/glob.js74
-rw-r--r--node_modules/glob/package.json4
-rw-r--r--node_modules/glob/test/mark.js8
3 files changed, 52 insertions, 34 deletions
diff --git a/node_modules/glob/glob.js b/node_modules/glob/glob.js
index 7903be18f..f4c69e973 100644
--- a/node_modules/glob/glob.js
+++ b/node_modules/glob/glob.js
@@ -214,27 +214,10 @@ Glob.prototype._finish = function () {
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.cache[m]
- if (!sc)
- return m
- var isDir = (Array.isArray(sc) || sc === 2)
- if (isDir && m.slice(-1) !== "/") {
- return m + "/"
- }
- if (!isDir && m.slice(-1) === "/") {
- return m.replace(/\/+$/, "")
- }
- return m
- }, this)
- }
-
this.log("emitting end", all)
this.EOF = this.found = all
- this.emitMatch(this.EOF)
+ this.emitMatch(this.EOF, -1)
}
function alphasorti (a, b) {
@@ -270,16 +253,47 @@ Glob.prototype.resume = function () {
//process.nextTick(this.emit.bind(this, "resume"))
}
-Glob.prototype.emitMatch = function (m) {
- if (!this.stat || this.statCache[m] || m === this.EOF) {
- this._emitQueue.push(m)
- this._processEmitQueue()
+Glob.prototype._mark = function (p) {
+ var c = this.cache[p]
+ var m = p
+ if (c) {
+ var isDir = c === 2 || Array.isArray(c)
+ var slash = p.slice(-1) === '/'
+
+ if (isDir && !slash)
+ m += '/'
+ else if (!isDir && slash)
+ m = m.slice(0, -1)
+
+ if (m !== p) {
+ this.statCache[m] = this.statCache[p]
+ this.cache[m] = this.cache[p]
+ }
+ }
+
+ return m
+}
+
+Glob.prototype._pushMatch = function(m, index) {
+ if (this.mark && m !== this.EOF)
+ m = this._mark(m)
+
+ if (m !== this.EOF) {
+ this.matches[index] = this.matches[index] || {}
+ this.matches[index][m] = true
+ }
+
+ this._emitQueue.push(m)
+ this._processEmitQueue()
+}
+
+Glob.prototype.emitMatch = function (m, index) {
+ if ((!this.stat && !this.mark) || this.statCache[m] || m === this.EOF) {
+ this._pushMatch(m, index)
} else {
this._stat(m, function(exists, isDir) {
- if (exists) {
- this._emitQueue.push(m)
- this._processEmitQueue()
- }
+ if (exists)
+ this._pushMatch(m, index)
})
}
}
@@ -353,9 +367,7 @@ Glob.prototype._process = function (pattern, depth, index, cb_) {
if (process.platform === "win32")
prefix = prefix.replace(/\\/g, "/")
- this.matches[index] = this.matches[index] || {}
- this.matches[index][prefix] = true
- this.emitMatch(prefix)
+ this.emitMatch(prefix, index)
}
return cb()
})
@@ -469,9 +481,7 @@ Glob.prototype._process = function (pattern, depth, index, cb_) {
if (process.platform === "win32")
e = e.replace(/\\/g, "/")
- this.matches[index] = this.matches[index] || {}
- this.matches[index][e] = true
- this.emitMatch(e)
+ this.emitMatch(e, index)
}, this)
return cb.call(this)
}
diff --git a/node_modules/glob/package.json b/node_modules/glob/package.json
index 3ae510111..8cd18eaf6 100644
--- a/node_modules/glob/package.json
+++ b/node_modules/glob/package.json
@@ -6,7 +6,7 @@
},
"name": "glob",
"description": "a little globber",
- "version": "3.2.7",
+ "version": "3.2.8",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/node-glob.git"
@@ -34,6 +34,6 @@
"url": "https://github.com/isaacs/node-glob/issues"
},
"homepage": "https://github.com/isaacs/node-glob",
- "_id": "glob@3.2.7",
+ "_id": "glob@3.2.8",
"_from": "glob@~3.2.6"
}
diff --git a/node_modules/glob/test/mark.js b/node_modules/glob/test/mark.js
index ed68a335c..e74282073 100644
--- a/node_modules/glob/test/mark.js
+++ b/node_modules/glob/test/mark.js
@@ -18,6 +18,8 @@ test("mark, no / on pattern", function (t) {
t.same(results, expect)
t.end()
+ }).on('match', function(m) {
+ t.similar(m, /\/$/)
})
})
@@ -36,6 +38,8 @@ test("mark=false, no / on pattern", function (t) {
expect.push('a/symlink')
t.same(results, expect)
t.end()
+ }).on('match', function(m) {
+ t.similar(m, /[^\/]$/)
})
})
@@ -53,6 +57,8 @@ test("mark=true, / on pattern", function (t) {
expect.push('a/symlink/')
t.same(results, expect)
t.end()
+ }).on('match', function(m) {
+ t.similar(m, /\/$/)
})
})
@@ -70,5 +76,7 @@ test("mark=false, / on pattern", function (t) {
expect.push('a/symlink/')
t.same(results, expect)
t.end()
+ }).on('match', function(m) {
+ t.similar(m, /\/$/)
})
})