diff --git a/package-lock.json b/package-lock.json index 532a68a..2400178 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@adafruit/circuitpython-repl-js", - "version": "1.2.3", + "version": "2.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@adafruit/circuitpython-repl-js", - "version": "1.2.3", + "version": "2.0.1", "license": "MIT", "devDependencies": {} } diff --git a/package.json b/package.json index adbac3a..aa6f221 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "publishConfig": { "registry": "https://npm.pkg.github.com" }, - "version": "1.2.3", + "version": "2.0.1", "description": "A JavaScript Module to help with interfacing to the REPL on CircuitPython Devices over serial", "main": "repl.js", "exports": { diff --git a/repl.js b/repl.js index c169975..dfb3600 100644 --- a/repl.js +++ b/repl.js @@ -64,10 +64,13 @@ export class FileOps { async _checkReplErrors() { let error = this._repl.getErrorOutput(); - if (error && error.type == "OSError" && error.errno == 30) { - this._isReadOnly = true; - // Throw an error if needed - await this._checkReadOnly(); + if (error) { + console.error("Python Error - " + error.type + ": " + error.message); + if (error.type == "OSError" && error.errno == 30) { + this._isReadOnly = true; + // Throw an error if needed + await this._checkReadOnly(); + } } return error; @@ -162,11 +165,11 @@ with open("${path}", "rb") as f: async _readTextFile(path) { try { let code = ` - with open("${path}", "r") as f: - print(f.read()) - `; +with open("${path}", "r") as f: + print(f.read()) +`; let result = await this._repl.execRawPasteMode(code); - if (this._checkReplErrors()) { + if (await this._checkReplErrors()) { return null; }