Port sanitychess.js to metadata.json

pull/1221/head
Adam Schmalhofer 2022-01-07 01:14:18 +01:00
parent d8d0dae4b5
commit 6f9cd73425
1 changed files with 27 additions and 22 deletions

View File

@ -26,15 +26,20 @@ function WARN(s) {
console.log("Warning: "+s);
}
var appsFile, apps;
try {
appsFile = fs.readFileSync(BASEDIR+"apps.json").toString();
} catch (e) {
ERROR("apps.json not found");
}
try{
apps = JSON.parse(appsFile);
} catch (e) {
var apps = [];
var dirs = fs.readdirSync(APPSDIR, {withFileTypes: true});
dirs.forEach(dir => {
var appsFile;
if (dir.name.startsWith("_example"))
return;
try {
appsFile = fs.readFileSync(APPSDIR+dir.name+"/metadata.json").toString();
} catch (e) {
return;
}
try{
apps.push(JSON.parse(appsFile));
} catch (e) {
console.log(e);
var m = e.toString().match(/in JSON at position (\d+)/);
if (m) {
@ -46,9 +51,9 @@ try{
console.log("===============================================");
}
console.log(m);
ERROR("apps.json not valid JSON");
}
ERROR(dir.name+"/metadata.json not valid JSON");
}
});
const APP_KEYS = [
'id', 'name', 'shortName', 'version', 'icon', 'screenshots', 'description', 'tags', 'type',