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.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/deps/npm/node_modules/glob/sync.js b/deps/npm/node_modules/glob/sync.js
index f9834dcd7b..c952134baa 100644
--- a/deps/npm/node_modules/glob/sync.js
+++ b/deps/npm/node_modules/glob/sync.js
@@ -250,16 +250,18 @@ GlobSync.prototype._readdirInGlobStar = function (abs) {
try {
lstat = fs.lstatSync(abs)
} catch (er) {
- // lstat failed, doesn't exist
- return null
+ if (er.code === 'ENOENT') {
+ // lstat failed, doesn't exist
+ return null
+ }
}
- var isSym = lstat.isSymbolicLink()
+ var isSym = lstat && lstat.isSymbolicLink()
this.symlinks[abs] = isSym
// If it's not a symlink or a dir, then it's definitely a regular file.
// don't bother doing a readdir in that case.
- if (!isSym && !lstat.isDirectory())
+ if (!isSym && lstat && !lstat.isDirectory())
this.cache[abs] = 'FILE'
else
entries = this._readdir(abs, false)
@@ -444,10 +446,13 @@ GlobSync.prototype._stat = function (f) {
try {
lstat = fs.lstatSync(abs)
} catch (er) {
- return false
+ if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
+ this.statCache[abs] = false
+ return false
+ }
}
- if (lstat.isSymbolicLink()) {
+ if (lstat && lstat.isSymbolicLink()) {
try {
stat = fs.statSync(abs)
} catch (er) {
@@ -460,10 +465,13 @@ GlobSync.prototype._stat = function (f) {
this.statCache[abs] = stat
- var c = stat.isDirectory() ? 'DIR' : 'FILE'
+ var c = true
+ if (stat)
+ c = stat.isDirectory() ? 'DIR' : 'FILE'
+
this.cache[abs] = this.cache[abs] || c
- if (needDir && c !== 'DIR')
+ if (needDir && c === 'FILE')
return false
return c