Skip to content

Fixed file extension calculation for ESP32 boards. #554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ lib
dist
es
.tmp
misc
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 10 additions & 2 deletions src/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
}
}