Fixed bin/firmwaremaker and bin/apploader CLI to handle binary file uploads correctly

pull/553/head
Gordon Williams 2020-08-25 11:46:33 +01:00
parent badc82f4fc
commit f417f8b1c9
3 changed files with 8 additions and 7 deletions

View File

@ -25,3 +25,4 @@ Changed for individual apps are listed in `apps/appname/ChangeLog`
* Fixed animated progress bar on app removal
* Added ability to specify dependencies (used for `notify` at the moment)
* Fixed Promise-based bug in removeApp
* Fixed bin/firmwaremaker and bin/apploader CLI to handle binary file uploads correctly

View File

@ -13,8 +13,8 @@ for Noble.
var SETTINGS = {
pretokenise : true
};
var Utils = require("../js/utils.js");
var AppInfo = require("../js/appinfo.js");
var Utils = require("../core/js/utils.js");
var AppInfo = require("../core/js/appinfo.js");
var noble;
try {
noble = require('@abandonware/noble');
@ -93,7 +93,7 @@ function cmdInstallApp(appId, deviceAddress) {
return AppInfo.getFiles(app, {
fileGetter:function(url) {
console.log(__dirname+"/"+url);
return Promise.resolve(require("fs").readFileSync(__dirname+"/../"+url).toString());
return Promise.resolve(require("fs").readFileSync(__dirname+"/../"+url).toString("binary"));
}, settings : SETTINGS}).then(files => {
//console.log(files);
var command = files.map(f=>f.cmd).join("\n")+"\n";
@ -223,7 +223,7 @@ function bangleSend(command, deviceAddress) {
if (!data.length) return callback();
var d = data.substr(0,20);
data = data.substr(20);
var buf = new Buffer(d.length);
var buf = new Buffer.alloc(d.length);
progress++;
if (progress>=10) {
log("Writing "+amt+"/"+total);

View File

@ -19,7 +19,7 @@ var APPS = [ // IDs of apps to install
var MINIFY = true;
var fs = require("fs");
var AppInfo = require(ROOTDIR+"/js/appinfo.js");
var AppInfo = require(ROOTDIR+"/core/js/appinfo.js");
var appjson = JSON.parse(fs.readFileSync(APPJSON).toString());
var appfiles = [];
@ -39,14 +39,14 @@ function fileGetter(url) {
if (url.endsWith(".json")) {
var f = url.slice(0,-5);
console.log("MINIFYING JSON "+f);
var j = eval("("+fs.readFileSync(url).toString()+")");
var j = eval("("+fs.readFileSync(url).toString("binary")+")");
var code = JSON.stringify(j);
//console.log(code);
url = f+".min.json";
fs.writeFileSync(url, code);
}
}
return Promise.resolve(fs.readFileSync(url).toString());
return Promise.resolve(fs.readFileSync(url).toString("binary"));
}
Promise.all(APPS.map(appid => {