mirror of
https://github.com/zkldi/Tachi.git
synced 2026-09-29 18:37:58 +03:00
30 lines
812 B
JavaScript
30 lines
812 B
JavaScript
const fs = require("fs");
|
|
const path = require("path");
|
|
const DeterministicCollectionSort = require("./deterministic-collection-sort");
|
|
|
|
function IterateCollections(cb) {
|
|
const main = path.join(__dirname, "../collections");
|
|
|
|
for (const collection of fs.readdirSync(main)) {
|
|
const data = cb(JSON.parse(fs.readFileSync(path.join(main, collection))));
|
|
|
|
fs.writeFileSync(path.join(main, collection), JSON.stringify(data, null, "\t"));
|
|
}
|
|
|
|
DeterministicCollectionSort();
|
|
}
|
|
|
|
function MutateCollection(name, cb) {
|
|
const main = path.join(__dirname, "../collections");
|
|
|
|
const data = cb(JSON.parse(fs.readFileSync(path.join(main, name))));
|
|
|
|
fs.writeFileSync(path.join(main, name), JSON.stringify(data, null, "\t"));
|
|
|
|
DeterministicCollectionSort();
|
|
}
|
|
|
|
module.exports = {
|
|
IterateCollections,
|
|
MutateCollection,
|
|
} |