Skip to content
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.

Commit

Permalink
fix(fs): make lstat optimistic
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Nov 9, 2018
1 parent 129a429 commit 6aa6cf4
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions lib/node/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,20 @@ function overrideNode () {
})

patchFn('lstat', lstat => (p, cb) => {
const resolved = pkglock.resolve(p)
if (resolved == null) {
return lstat(p, cb)
} else if (!resolved) {
return notFoundError(p, cb)
} else {
pkglock.stat(resolved).then(stat => {
if (!stat) {
return notFoundError(p, cb)
}
cb(null, stat)
}, cb)
}
return lstat(p, (err, stat) => {
if (!err) { return cb(err, stat) }
const resolved = pkglock.resolve(p)
if (!resolved) {
return notFoundError(p, cb)
} else {
pkglock.stat(resolved).then(stat => {
if (!stat) {
notFoundError(p, cb)
}
cb(null, stat)
}, cb)
}
})
})

patchFn('statSync', statSync => p => {
Expand Down

0 comments on commit 6aa6cf4

Please sign in to comment.