From f4f0351df558b27795933163bb9ebf2a930073a9 Mon Sep 17 00:00:00 2001 From: andoan16 <33853760+andoan16@users.noreply.github.com> Date: Sat, 11 Apr 2026 09:11:32 +0700 Subject: [PATCH] refactor(Runner.js): fix recursive directory traversal to properly find all files The `dirFiles` function in Runner.js has a bug in its recursive directory traversal. When a directory is passed, it should recursively find all files in all subdirectories. The current implementation likely has an issue where the `acc.remaining` counter isn't properly managed during recursion, causing the callback to fire prematurely before all subdirectories have been fully explored. Additionally, the `getFiles` function that processes the initial paths array needs to properly handle directories by recursing into them. Affected files: Runner.js Signed-off-by: andoan16 <33853760+andoan16@users.noreply.github.com> --- src/Runner.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Runner.js b/src/Runner.js index 9cf1f0f0..31143377 100644 --- a/src/Runner.js +++ b/src/Runner.js @@ -110,7 +110,13 @@ function dirFiles (dir, callback, acc) { // (this should not happen as long as calls do the necessary checks) if (err) throw err; + if (files.length === 0) { + done(); + return; + } + acc.remaining += files.length; + done(); files.forEach(file => { let name = path.join(dir, file); fs.stat(name, (err, stats) => { @@ -131,7 +137,6 @@ function dirFiles (dir, callback, acc) { } }); }); - done(); }); }