more compatible app loader

pull/1330/head
Gordon Williams 2022-01-20 17:08:31 +00:00
parent 72e9a576e0
commit e997ad59ed
1 changed files with 16 additions and 6 deletions

View File

@ -13,6 +13,7 @@ for Noble.
var SETTINGS = {
pretokenise : true
};
var APPSDIR = __dirname+"/../apps/";
var Utils = require("../core/js/utils.js");
var AppInfo = require("../core/js/appinfo.js");
var noble;
@ -29,18 +30,27 @@ if (!noble) {
console.log(" npm install noble")
}
var apps;
var apps = [];
function ERROR(msg) {
console.error(msg);
process.exit(1);
}
var apps = [];
var dirs = require("fs").readdirSync(APPSDIR, {withFileTypes: true});
dirs.forEach(dir => {
var appsFile;
if (dir.name.startsWith("_example") || !dir.isDirectory())
return;
try {
apps = JSON.parse(require("fs").readFileSync(__dirname+"/../apps.json"));
appsFile = require("fs").readFileSync(APPSDIR+dir.name+"/metadata.json").toString();
} catch (e) {
ERROR("'apps.json' could not be loaded");
ERROR(dir.name+"/metadata.json does not exist");
return;
}
apps.push(JSON.parse(appsFile));
});
var args = process.argv;