node-klaw-sync icon indicating copy to clipboard operation
node-klaw-sync copied to clipboard

Use lstatSync instead of statSync

Open ericclemmons opened this issue 4 years ago • 0 comments

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

This fixes https://github.com/manidlou/node-klaw-sync/issues/17.

Here is the diff that solved my problem:

diff --git a/node_modules/klaw-sync/klaw-sync.js b/node_modules/klaw-sync/klaw-sync.js
index 74b87c6..6e7689a 100644
--- a/node_modules/klaw-sync/klaw-sync.js
+++ b/node_modules/klaw-sync/klaw-sync.js
@@ -13,7 +13,7 @@ function klawSync (dir, opts, ls) {
   const paths = opts.fs.readdirSync(dir).map(p => dir + path.sep + p)
   for (var i = 0; i < paths.length; i += 1) {
     const pi = paths[i]
-    const st = opts.fs.statSync(pi)
+    const st = opts.fs.lstatSync(pi)
     const item = {path: pi, stats: st}
     const isUnderDepthLimit = (!opts.rootDepth || pi.split(path.sep).length - opts.rootDepth < opts.depthLimit)
     const filterResult = opts.filter ? opts.filter(item) : true

This issue body was partially generated by patch-package.

ericclemmons avatar Jul 08 '21 17:07 ericclemmons