From a4480bd7aec3af98ae710e5b9095cb25e35fc338 Mon Sep 17 00:00:00 2001 From: Guillaume Wuip Date: Tue, 11 Nov 2014 18:23:39 +0100 Subject: [PATCH] Fix: check err after anything else --- lib/webPanel.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/webPanel.js b/lib/webPanel.js index 22db2df..2d863a6 100644 --- a/lib/webPanel.js +++ b/lib/webPanel.js @@ -64,11 +64,16 @@ fs.readdir(dirPath, function (err, list) { var dir = []; - list.forEach(function (item) { - dir.push(readNode(path.join(dirPath, item))); - }); + if (err) { + callback(err, null); + } else { + list.forEach(function (item) { + dir.push(readNode(path.join(dirPath, item))); + }); + + callback(null, dir); + } - callback(null, dir); }); }