apple2js/bin/index
Will Scullin bb6e36f964
Various fixes (#23)
* Sort disks in category order

* Fix saving disk

* Fix keyboard not working after modal

* Make caps lock key on keyboard work, while keeping caps lock on virtual keyboard working too

* Fix delete local storage

* Fix minus key on Mac

* Remove backtick

* Credit.

Co-authored-by: Matthew Hebley <Matthew.Hebley@navico.com>
2020-04-23 19:47:44 -07:00

52 lines
1.1 KiB
JavaScript
Executable File

#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const diskPath = path.resolve('json/disks');
const dir = fs.readdirSync(diskPath);
const index = [];
for (const fileName of dir.sort()) {
if (/\.json$/.test(fileName)) {
const json = fs.readFileSync(path.resolve(diskPath, fileName));
const data = JSON.parse(json);
if (data.private) { continue; }
const entry = {
filename: `json/disks/${fileName}`,
e: data['2e'],
name: data.name,
disk: data.disk,
category: data.category,
};
index.push(entry);
}
}
index.sort((x,y) => {
const xc = x.category.toLowerCase();
const yc = y.category.toLowerCase();
const xn = x.name.toLowerCase();
const yn = y.name.toLowerCase();
if (xc < yc) {
return -1;
} else if (xc > yc) {
return 1;
} else if (xn < yn) {
return -1;
} else if (xn > yn) {
return 1;
} else {
return 0;
}
});
fs.writeFileSync(
path.resolve(diskPath, 'index.js'),
`disk_index = ${JSON.stringify(index, null, 2)};`
);