diff --git a/.gitignore b/.gitignore index 22641d8..c3e6649 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ lib dist es .tmp +misc diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a2560a..cc4c1bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,12 @@ # Changelog All notable changes to this project will be documented in this file. -## [2.9.1] - 2022-09-06 +## [2.10.0] - 2022-09-08 + +### Changed +- Fixed a bug released in 2.9.1 caused by the wrong assumption that the build filename is always at the end of the command line. This fix makes the library backward compatible with older ESP boards. + +## *DEPRECATED* [2.9.1] - 2022-09-06 ### Added - Added support for ESP32 boards diff --git a/README.md b/README.md index 0694481..3f03870 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ JS module providing discovery of the [Arduino Create Agent](https://github.com/arduino/arduino-create-agent) and communication with it ## Changelog -See [CHANGELOG.MD](CHANGELOG.MD) for more details. +See [CHANGELOG.md](https://github.com/arduino/arduino-create-agent-js-client/blob/HEAD/CHANGELOG.md) for more details. ## Installation diff --git a/package.json b/package.json index bb40417..39bb739 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "arduino-create-agent-js-client", - "version": "2.9.1", + "version": "2.10.0", "description": "JS module providing discovery of the Arduino Create Plugin and communication with it", "main": "lib/index.js", "module": "es/index.js", diff --git a/src/daemon.js b/src/daemon.js index 4846c41..cf6c191 100644 --- a/src/daemon.js +++ b/src/daemon.js @@ -130,8 +130,7 @@ export default class Daemon { }) .then(result => result.json()) .then(uploadCommandInfo => { - const projectNameIndex = uploadCommandInfo.commandline.lastIndexOf('{build.project_name}'); - let ext = uploadCommandInfo.commandline.substring(projectNameIndex + 21, projectNameIndex + 24); + let ext = this._extractExtensionFromCommandline(uploadCommandInfo.commandline); const data = compilationResult[ext] || compilationResult.bin; if (!ext || !data) { console.log('we received a faulty ext property, defaulting to .bin'); @@ -211,4 +210,13 @@ export default class Daemon { }); this.openSerialMonitor(port, 1200); } + + static _extractExtensionFromCommandline(commandline) { + const rx = /\{build\.project_name\}\.(\w\w\w)\b/g; + const arr = rx.exec(commandline); + if (arr && arr.length) { + return arr[1]; + } + return null; + } }