summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/glob/sync.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/glob/sync.js')
-rw-r--r--deps/npm/node_modules/glob/sync.js73
1 files changed, 37 insertions, 36 deletions
diff --git a/deps/npm/node_modules/glob/sync.js b/deps/npm/node_modules/glob/sync.js
index a7f9f52daf..f981055af9 100644
--- a/deps/npm/node_modules/glob/sync.js
+++ b/deps/npm/node_modules/glob/sync.js
@@ -1,15 +1,16 @@
module.exports = globSync
globSync.GlobSync = GlobSync
-var fs = require("fs")
-var minimatch = require("minimatch")
+var fs = require('fs')
+var minimatch = require('minimatch')
var Minimatch = minimatch.Minimatch
-var Glob = require("./glob.js").Glob
-var util = require("util")
-var path = require("path")
-var assert = require("assert")
-var common = require("./common.js")
+var Glob = require('./glob.js').Glob
+var util = require('util')
+var path = require('path')
+var assert = require('assert')
+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
@@ -23,7 +24,7 @@ function globSync (pattern, options) {
function GlobSync (pattern, options) {
if (!pattern)
- throw new Error("must provide pattern")
+ throw new Error('must provide pattern')
if (typeof options === 'function' || arguments.length === 3)
throw new TypeError('callback provided to sync glob')
@@ -55,7 +56,7 @@ GlobSync.prototype._process = function (pattern, index, inGlobStar) {
// 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.
@@ -76,9 +77,9 @@ GlobSync.prototype._process = function (pattern, index, inGlobStar) {
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
}
@@ -87,10 +88,10 @@ GlobSync.prototype._process = function (pattern, index, inGlobStar) {
// 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
@@ -116,12 +117,12 @@ GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index,
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)
@@ -150,13 +151,13 @@ GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index,
for (var i = 0; i < len; i ++) {
var e = matchedEntries[i]
if (prefix) {
- if (prefix.slice(-1) !== "/")
- e = prefix + "/" + e
+ if (prefix.slice(-1) !== '/')
+ 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.matches[index][e] = true
@@ -235,7 +236,7 @@ GlobSync.prototype._readdir = function (abs, inGlobStar) {
}
try {
- return this._readdirEntries(abs, fs.readdirSync(abs).sort(alphasort))
+ return this._readdirEntries(abs, fs.readdirSync(abs))
} catch (er) {
this._readdirError(abs, er)
return null
@@ -249,10 +250,10 @@ GlobSync.prototype._readdirEntries = function (abs, entries) {
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
}
}
@@ -266,21 +267,21 @@ GlobSync.prototype._readdirEntries = function (abs, entries) {
GlobSync.prototype._readdirError = function (f, er) {
// 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) throw er
- if (!this.silent) console.error("glob error", er)
+ if (!this.silent) console.error('glob error', er)
break
}
}
@@ -312,7 +313,7 @@ GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index
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
@@ -338,7 +339,7 @@ GlobSync.prototype._processSimple = function (prefix, index) {
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)
@@ -347,8 +348,8 @@ GlobSync.prototype._processSimple = function (prefix, index) {
}
}
- if (process.platform === "win32")
- prefix = prefix.replace(/\\/g, "/")
+ if (process.platform === 'win32')
+ prefix = prefix.replace(/\\/g, '/')
// Mark this as a match
this.matches[index][prefix] = true
@@ -357,7 +358,7 @@ GlobSync.prototype._processSimple = function (prefix, index) {
// Returns either 'DIR', 'FILE', or false
GlobSync.prototype._stat = function (f) {
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)
@@ -373,7 +374,7 @@ GlobSync.prototype._stat = function (f) {
c = 'DIR'
// It exists, but not how we need it
- if (abs.slice(-1) === "/" && c !== 'DIR')
+ if (abs.slice(-1) === '/' && c !== 'DIR')
return false
return c
@@ -391,7 +392,7 @@ GlobSync.prototype._stat = function (f) {
this.statCache[abs] = stat
- if (abs.slice(-1) === "/" && !stat.isDirectory())
+ if (abs.slice(-1) === '/' && !stat.isDirectory())
return false
var c = stat.isDirectory() ? 'DIR' : 'FILE'