Skip to content

Commit

Permalink
Allow EspruinoTools to work even if Peer.js can't be installed (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Apr 3, 2024
1 parent d572c5e commit 69cf25c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ function loadJS(filePath) {
var contents = fs.readFileSync(filePath, {encoding:"utf8"});
var realExports = exports;
exports = undefined;
var r = eval(contents);
var r;
try {
r = eval(contents);
} catch (e) {
console.log("ERROR "+e+" while loading "+filePath);
}
exports = realExports; // utf8 lib somehow breaks this
return r;
/* the code below would be better, but it doesn't seem to work when running
Expand Down
4 changes: 2 additions & 2 deletions libs/webrtc-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ if (typeof Peer == "undefined") {
}
if (typeof Peer == "undefined") {
console.log("webrtc-connection: Peer.js not loaded - Remote Connection disabled");
throw false;
throw "No Peer.js implementation available";
}

var peer; // peer.js connection
Expand Down Expand Up @@ -418,4 +418,4 @@ function webrtcInit(options) {

// Fix for running under Node.js
if (typeof global != "undefined")
global.webrtcInit = webrtcInit;
global.webrtcInit = webrtcInit;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "espruino",
"version": "0.1.54",
"version": "0.1.55",
"description": "Command Line Interface and library for Communications with Espruino JavaScript Microcontrollers",
"main": "index.js",
"files": [
Expand Down

0 comments on commit 69cf25c

Please sign in to comment.