From 5be7015246ad64d6526858e332ac6fa2ba22ddb4 Mon Sep 17 00:00:00 2001 From: Kevin Malakoff Date: Tue, 2 Jan 2018 20:18:06 -0800 Subject: [PATCH] Tried advice from: https://github.com/kmalakoff/walk-filtered/issues/2 --- index.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 1ed87cf..cdadddd 100644 --- a/index.js +++ b/index.js @@ -44,7 +44,25 @@ function processPath(fullPath, options, callback) { if (err) return callback(err); if (!keep) return callback(); // do not keep processing - processDirectory(fullPath, options, callback); // eslint-disable-line no-use-before-define + fs.lstat(fullPath, function(err2, stat2) { + if (err2) return callback(err2); + + if (stat2.isSymbolicLink()) { + fs.stat(fullPath, function(err3, stat3) { + if (err3) return callback(err3); + + if (stat3.isDirectory()) { + processDirectory(fullPath, options, callback); // eslint-disable-line no-use-before-define + } else { + callback(); + } + }); + } else if (stat2.isDirectory()) { + processDirectory(fullPath, options, callback); // eslint-disable-line no-use-before-define + } else { + callback(); + } + }); }); } catch (err) { callback(err);