Skip to content

Commit

Permalink
fsinfo operation will fail in case there are no files on the esp module
Browse files Browse the repository at this point in the history
  • Loading branch information
AndiDittrich committed Jan 24, 2016
1 parent 53fb974 commit e607f1d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 1.3.2 ###
* Bugfix: `fsinfo` operation will fail in case there are no files on the esp module - thanks to [soldair on GitHub](https://github.com/AndiDittrich/NodeMCU-Tool/pull/1)

### 1.3.1 ###
* Bugfix: Tool throws a fatal error in case `.nodemcutool` file is not available

Expand Down
21 changes: 13 additions & 8 deletions lib/NodeMcuConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,27 +317,32 @@ NodeMcuConnector.prototype.fsinfo = function(cb){
return;
}

if (response.length == 0){
cb(null, meta, {});
}else{
var entries = response.trim().split(';');
// file-list to return
var files = [];

var files = [];
// files available (list not empty) ?
if (response.length > 0){
// split the file-list by ";"
var entries = response.trim().split(';');

// process each entry
entries.forEach(function(entry){
// entry format: <name>:<size>
var matches = /^(.*):(\d+)$/gi.exec(entry);

// valid format ?
if (matches){
// append file entry to list
files.push({
name: matches[1],
size: parseInt(matches[2])
});
}
});

// run callback
cb(null, meta, files);
}

// run callback
cb(null, meta, files);
});
}.bind(this));
};
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nodemcu-tool",
"version": "1.3.1",
"version": "1.3.2",
"description": "Command line tool to upload and manage files on your NodeMCU / ESP8266 Module.",
"keywords": [
"cli",
Expand Down Expand Up @@ -32,7 +32,7 @@
"author": "Andi Dittrich (http://andidittrich.de)",
"license": "MIT",
"dependencies": {
"cli-progress": "^1.0.1",
"cli-progress": "^1.1.1",
"colors": "^1.1.2",
"commander": "^2.9.0",
"prompt": "^0.2.14",
Expand Down

0 comments on commit e607f1d

Please sign in to comment.