diff options
author | Forrest L Norvell <forrest@npmjs.com> | 2015-01-23 06:56:30 -0800 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2015-01-23 23:19:27 +0100 |
commit | f5b35dbda45c466eda888a4451591c66e8671faf (patch) | |
tree | fe89dd3e105a3693bd0776c678813dadae21065d /deps/npm/node_modules/glob/glob.js | |
parent | f3fed5193caaac151acd555a7523068ee269801c (diff) | |
download | node-new-f5b35dbda45c466eda888a4451591c66e8671faf.tar.gz |
deps: upgrade npm to 2.3.0
* Windows improvements: no more uid is undefined errors, use `%COMSPEC%`
when set in preference to hardcoded `cmd`, improved handling of Git
remotes.
* Add caching based on Last-Modified / If-Modified-Since headers in
addition to Etag-based cache validation.
PR-URL: https://github.com/iojs/io.js/pull/573
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/npm/node_modules/glob/glob.js')
-rw-r--r-- | deps/npm/node_modules/glob/glob.js | 123 |
1 files changed, 62 insertions, 61 deletions
diff --git a/deps/npm/node_modules/glob/glob.js b/deps/npm/node_modules/glob/glob.js index 8c99078218..7401e0b7e9 100644 --- a/deps/npm/node_modules/glob/glob.js +++ b/deps/npm/node_modules/glob/glob.js @@ -40,26 +40,27 @@ module.exports = glob -var fs = require("fs") -var minimatch = require("minimatch") +var fs = require('fs') +var minimatch = require('minimatch') var Minimatch = minimatch.Minimatch -var inherits = require("inherits") -var EE = require("events").EventEmitter -var path = require("path") -var assert = require("assert") -var globSync = require("./sync.js") -var common = require("./common.js") +var inherits = require('inherits') +var EE = require('events').EventEmitter +var path = require('path') +var assert = require('assert') +var globSync = require('./sync.js') +var common = require('./common.js') var alphasort = common.alphasort +var alphasorti = common.alphasorti var isAbsolute = common.isAbsolute var setopts = common.setopts var ownProp = common.ownProp -var inflight = require("inflight") -var util = require("util") +var inflight = require('inflight') +var util = require('util') -var once = require("once") +var once = require('once') function glob (pattern, options, cb) { - if (typeof options === "function") cb = options, options = {} + if (typeof options === 'function') cb = options, options = {} if (!options) options = {} if (options.sync) { @@ -97,7 +98,7 @@ glob.hasMagic = function (pattern, options_) { glob.Glob = Glob inherits(Glob, EE) function Glob (pattern, options, cb) { - if (typeof options === "function") { + if (typeof options === 'function') { cb = options options = null } @@ -122,10 +123,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 (typeof cb === "function") { + if (typeof cb === 'function') { cb = once(cb) - this.on("error", cb) - this.on("end", function (matches) { + this.on('error', cb) + this.on('end', function (matches) { cb(null, matches) }) } @@ -163,7 +164,7 @@ Glob.prototype._finish = function () { //console.error('FINISH', this.matches) common.finish(this) - this.emit("end", this.found) + this.emit('end', this.found) } Glob.prototype._mark = function (p) { @@ -176,19 +177,19 @@ Glob.prototype._makeAbs = function (f) { Glob.prototype.abort = function () { this.aborted = true - this.emit("abort") + this.emit('abort') } Glob.prototype.pause = function () { if (!this.paused) { this.paused = true - this.emit("pause") + this.emit('pause') } } Glob.prototype.resume = function () { if (this.paused) { - this.emit("resume") + this.emit('resume') this.paused = false if (this._emitQueue.length) { var eq = this._emitQueue.slice(0) @@ -223,11 +224,11 @@ Glob.prototype._process = function (pattern, index, inGlobStar, cb) { return } - //console.error("PROCESS %d", this._processing, pattern) + //console.error('PROCESS %d', this._processing, pattern) // Get the first [n] parts of pattern that are all strings. var n = 0 - while (typeof pattern[n] === "string") { + while (typeof pattern[n] === 'string') { n ++ } // now n is the index of the first one that is *not* a string. @@ -248,9 +249,9 @@ Glob.prototype._process = function (pattern, index, inGlobStar, cb) { 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).join("/") + // whatever it starts with, whether that's 'absolute' like /foo/bar, + // or 'relative' like '../baz' + prefix = pattern.slice(0, n).join('/') break } @@ -259,10 +260,10 @@ Glob.prototype._process = function (pattern, index, inGlobStar, cb) { // get the list of entries. var read if (prefix === null) - read = "." - else if (isAbsolute(prefix) || isAbsolute(pattern.join("/"))) { + read = '.' + else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { if (!prefix || !isAbsolute(prefix)) - prefix = "/" + prefix + prefix = '/' + prefix read = prefix } else read = prefix @@ -295,12 +296,12 @@ Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, in var pn = remain[0] var negate = !!this.minimatch.negate var rawGlob = pn._glob - var dotOk = this.dot || rawGlob.charAt(0) === "." + var dotOk = this.dot || rawGlob.charAt(0) === '.' var matchedEntries = [] for (var i = 0; i < entries.length; i++) { var e = entries[i] - if (e.charAt(0) !== "." || dotOk) { + if (e.charAt(0) !== '.' || dotOk) { var m if (negate && !prefix) { m = !e.match(pn) @@ -331,13 +332,13 @@ Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, in for (var i = 0; i < len; i ++) { var e = matchedEntries[i] if (prefix) { - if (prefix !== "/") - e = prefix + "/" + e + if (prefix !== '/') + e = prefix + '/' + e else e = prefix + e } - if (e.charAt(0) === "/" && !this.nomount) { + if (e.charAt(0) === '/' && !this.nomount) { e = path.join(this.root, e) } this._emitMatch(index, e) @@ -353,8 +354,8 @@ Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, in var e = matchedEntries[i] var newPattern if (prefix) { - if (prefix !== "/") - e = prefix + "/" + e + if (prefix !== '/') + e = prefix + '/' + e else e = prefix + e } @@ -381,12 +382,12 @@ Glob.prototype._emitMatch = function (index, e) { this.matches[index][e] = true if (!this.stat && !this.mark) - return this.emit("match", e) + return this.emit('match', e) var self = this this._stat(this._makeAbs(e), function (er, c, st) { - self.emit("stat", e, st) - self.emit("match", e) + self.emit('stat', e, st) + self.emit('match', e) }) } } @@ -395,7 +396,7 @@ Glob.prototype._readdirInGlobStar = function (abs, cb) { if (this.aborted) return - var lstatkey = "lstat\0" + abs + var lstatkey = 'lstat\0' + abs var self = this var lstatcb = inflight(lstatkey, lstatcb_) @@ -423,11 +424,11 @@ Glob.prototype._readdir = function (abs, inGlobStar, cb) { if (this.aborted) return - cb = inflight("readdir\0"+abs+"\0"+inGlobStar, cb) + cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb) if (!cb) return - //console.error("RD %j %j", +inGlobStar, abs) + //console.error('RD %j %j', +inGlobStar, abs) if (inGlobStar && !ownProp(this.symlinks, abs)) return this._readdirInGlobStar(abs, cb) @@ -449,7 +450,7 @@ function readdirCb (self, abs, cb) { if (er) self._readdirError(abs, er, cb) else - self._readdirEntries(abs, entries.sort(alphasort), cb) + self._readdirEntries(abs, entries, cb) } } @@ -463,10 +464,10 @@ Glob.prototype._readdirEntries = function (abs, entries, cb) { if (!this.mark && !this.stat) { for (var i = 0; i < entries.length; i ++) { var e = entries[i] - if (abs === "/") + if (abs === '/') e = abs + e else - e = abs + "/" + e + e = abs + '/' + e this.cache[e] = true } } @@ -481,21 +482,21 @@ Glob.prototype._readdirError = function (f, er, cb) { // handle errors, and cache the information switch (er.code) { - case "ENOTDIR": // totally normal. means it *does* exist. + case 'ENOTDIR': // totally normal. means it *does* exist. this.cache[f] = 'FILE' break - case "ENOENT": // not terribly unusual - case "ELOOP": - case "ENAMETOOLONG": - case "UNKNOWN": + case 'ENOENT': // not terribly unusual + case 'ELOOP': + case 'ENAMETOOLONG': + case 'UNKNOWN': this.cache[f] = false break default: // some unusual error. Treat as failure. this.cache[f] = false - if (this.strict) return this.emit("error", er) - if (!this.silent) console.error("glob error", er) + if (this.strict) return this.emit('error', er) + if (!this.silent) console.error('glob error', er) break } return cb() @@ -510,7 +511,7 @@ Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, in Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { - //console.error("pgs2", prefix, remain[0], entries) + //console.error('pgs2', prefix, remain[0], entries) // no entries means not a dir, so it can never have matches // foo.txt/** doesn't match foo.txt @@ -535,7 +536,7 @@ Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, i for (var i = 0; i < len; i++) { var e = entries[i] - if (e.charAt(0) === "." && !this.dot) + if (e.charAt(0) === '.' && !this.dot) continue // these two cases enter the inGlobStar state @@ -559,7 +560,7 @@ Glob.prototype._processSimple = function (prefix, index, cb) { } Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) { - //console.error("ps2", prefix, exists) + //console.error('ps2', prefix, exists) if (!this.matches[index]) this.matches[index] = Object.create(null) @@ -570,7 +571,7 @@ Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) { if (prefix && isAbsolute(prefix) && !this.nomount) { var trail = /[\/\\]$/.test(prefix) - if (prefix.charAt(0) === "/") { + if (prefix.charAt(0) === '/') { prefix = path.join(this.root, prefix) } else { prefix = path.resolve(this.root, prefix) @@ -579,8 +580,8 @@ Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) { } } - if (process.platform === "win32") - prefix = prefix.replace(/\\/g, "/") + if (process.platform === 'win32') + prefix = prefix.replace(/\\/g, '/') // Mark this as a match this._emitMatch(index, prefix) @@ -590,7 +591,7 @@ Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) { // Returns either 'DIR', 'FILE', or false Glob.prototype._stat = function (f, cb) { var abs = f - if (f.charAt(0) === "/") + if (f.charAt(0) === '/') abs = path.join(this.root, f) else if (this.changedCwd) abs = path.resolve(this.cwd, f) @@ -606,7 +607,7 @@ Glob.prototype._stat = function (f, cb) { c = 'DIR' // It exists, but not how we need it - if (abs.slice(-1) === "/" && c !== 'DIR') + if (abs.slice(-1) === '/' && c !== 'DIR') return cb() return cb(null, c) @@ -622,7 +623,7 @@ Glob.prototype._stat = function (f, cb) { } var self = this - var statcb = inflight("stat\0" + abs, statcb_) + var statcb = inflight('stat\0' + abs, statcb_) if (statcb) fs.stat(abs, statcb) @@ -639,7 +640,7 @@ Glob.prototype._stat2 = function (f, abs, er, stat, cb) { this.statCache[abs] = stat - if (abs.slice(-1) === "/" && !stat.isDirectory()) + if (abs.slice(-1) === '/' && !stat.isDirectory()) return cb(null, false, stat) var c = stat.isDirectory() ? 'DIR' : 'FILE' |