Skip to content

Commit

Permalink
Moved directory check into try-catch block #20
Browse files Browse the repository at this point in the history
take care of the scope of fileInfo
  • Loading branch information
Andi Dittrich authored Nov 30, 2016
1 parent 709ecd7 commit ff6999b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/NodeMCU-Tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 + '"...');
Expand Down

0 comments on commit ff6999b

Please sign in to comment.