diff --git a/lib/node/fs.js b/lib/node/fs.js index 58e160a..eface77 100644 --- a/lib/node/fs.js +++ b/lib/node/fs.js @@ -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 => {