Skip to content

Commit 8eb606c

Browse files
committed
Ensure -o outputs as binary (not UTF8), and that pretokenise works
Allow forcing of pretokenise via the CLI where we may not know the version
1 parent f58798f commit 8eb606c

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

bin/espruino-cli.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ function sendCode(callback) {
459459
}
460460
if (!args.outputHEX) {
461461
// if we're supposed to upload code somewhere ensure we do that properly
462+
if (args.outputJS)
463+
Espruino.Config.SAVE_ON_SEND = -1; // force tools not to mess with the file
462464
for (var storageName in args.storageContents) {
463465
var storageContent = args.storageContents[storageName];
464466
if (storageContent.code) {
@@ -497,7 +499,7 @@ function sendCode(callback) {
497499
}
498500
if (args.outputJS) {
499501
log("Writing output to "+args.outputJS);
500-
require("fs").writeFileSync(args.outputJS, code);
502+
require("fs").writeFileSync(args.outputJS, code, "binary");
501503
}
502504
if (!args.nosend)
503505
Espruino.Core.CodeWriter.writeToEspruino(code, function() {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "espruino",
3-
"version": "0.1.55",
3+
"version": "0.1.56",
44
"description": "Command Line Interface and library for Communications with Espruino JavaScript Microcontrollers",
55
"main": "index.js",
66
"files": [

plugins/pretokenise.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@
1919
function init() {
2020
Espruino.Core.Config.add("PRETOKENISE", {
2121
section : "Minification",
22-
name : "Pretokenise code before upload (BETA)",
22+
name : "Pretokenise code before upload",
2323
description : "All whitespace and comments are removed and all reserved words are converted to tokens before upload. This means a faster upload, less memory used, and increased performance (+10%) at the expense of code readability.",
24-
type : "boolean",
25-
defaultValue : false
24+
type : {
25+
0: "Never",
26+
1: "Auto (tokenise Strings on 2v20.48 or later)",
27+
2: "Yes (always tokenise everything, regardless of version)"
28+
},
29+
defaultValue : 0
2630
});
2731

2832
// When code is sent to Espruino, search it for modules and add extra code required to load them
@@ -120,7 +124,9 @@
120124
function pretokenise(code, callback) {
121125
var pretokeniseStrings = false; // only works on 2v20.48 and later
122126
var boardData = Espruino.Core.Env.getBoardData();
123-
if (boardData && boardData.VERSION) {
127+
if (Espruino.Config.PRETOKENISE==2) {
128+
pretokeniseStrings = true; // always
129+
} else if (boardData && boardData.VERSION) {
124130
var v = parseFloat(boardData.VERSION.replace("v","0"));
125131
if (v >= 2020.48)
126132
pretokeniseStrings = true;

0 commit comments

Comments
 (0)