From ff6999bff89b11deb43116dce46d081a7fbee037 Mon Sep 17 00:00:00 2001 From: Andi Dittrich Date: Wed, 30 Nov 2016 21:41:02 +0100 Subject: [PATCH] Moved directory check into try-catch block #20 take care of the scope of fileInfo --- lib/NodeMCU-Tool.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/NodeMCU-Tool.js b/lib/NodeMCU-Tool.js index 4f7f1fb..2ce9d0b 100755 --- a/lib/NodeMCU-Tool.js +++ b/lib/NodeMCU-Tool.js @@ -142,19 +142,20 @@ Tool.upload = function(localFiles, options, onProgess){ // get file stats try{ var fileInfo = _fs.statSync(localFile); + + // check if file is directory + if (fileInfo.isDirectory()) { + _mculogger.error('Path "' + localFile + '" is a directory.'); + onComplete(); + return; + } + // local file available } catch (err){ _logger.error('Local file not found "' + localFile + '" skipping...'); onComplete(); return; } - - // check if file is directory - if (fileInfo.isDirectory()) { - _mculogger.error('Path "' + localFile + '" is a directory.'); - onComplete(); - return; - } // display filename _logger.log('Uploading "' + localFile + '" >> "' + remoteFilename + '"...');