From f70bf27594b4f5fc258184e8c8fb1f69feabdd49 Mon Sep 17 00:00:00 2001 From: Andi Dittrich Date: Sat, 12 Mar 2016 20:43:33 +0000 Subject: [PATCH] added basename filter to local filename when downloading files - strips path information --- README.md | 2 +- lib/NodeMCU-Tool.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fb81cf5..501f989 100755 --- a/README.md +++ b/README.md @@ -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 ` diff --git a/lib/NodeMCU-Tool.js b/lib/NodeMCU-Tool.js index 03d6bfc..35ea2a2 100755 --- a/lib/NodeMCU-Tool.js +++ b/lib/NodeMCU-Tool.js @@ -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); @@ -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)){