Skip to content

Commit

Permalink
added basename filter to local filename when downloading files - stri…
Browse files Browse the repository at this point in the history
…ps path information
  • Loading branch information
AndiDittrich committed Mar 12, 2016
1 parent 957956f commit f70bf27
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ The remote file name will be "MyFile.txt"

### Download Files ###
To backup files or fetch recorded data, NodeMCU-Tool allows you to download these files from NodeMCU using the `download` command.
A file with the same name as the remote-file is created in the current working directory.
A file with the same name as the remote-file is created in the current working directory - the path is dropped!

**Syntax** `nodemcu-tool [options] download <remote-filename>`

Expand Down
4 changes: 3 additions & 1 deletion lib/NodeMCU-Tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var _fs = require('fs');
var _nodeMcuConnector = require('./NodeMcuConnector');
var _serialTerminal = require('./SerialTerminal');
var _path = require('path');

// global default error handler
var errorHandler = function(source, error){
console.error('[' + source + '] ' + error);
Expand Down Expand Up @@ -155,7 +156,8 @@ var Tool = {

// download a remote file from nodemcu
download: function(port, baud, remoteFile){
var localFilename = remoteFile;
// strip path
var localFilename = _path.basename(remoteFile);

// local file with same name already available ?
if (_fs.existsSync(remoteFile)){
Expand Down

0 comments on commit f70bf27

Please sign in to comment.