2022-05-28 23:14:55 +08:00
|
|
|
const fs = require("fs");
|
|
|
|
|
|
|
|
function fixQuoteLengths() {
|
2024-03-12 03:00:10 +08:00
|
|
|
return new Promise((resolve) => {
|
2022-05-28 23:14:55 +08:00
|
|
|
const quotesFiles = fs.readdirSync("../static/quotes/");
|
|
|
|
quotesFiles.forEach((quotefilename) => {
|
|
|
|
quotefilename = quotefilename.split(".")[0];
|
|
|
|
let quoteData = JSON.parse(
|
|
|
|
fs.readFileSync(`../static/quotes/${quotefilename}.json`, {
|
|
|
|
encoding: "utf8",
|
|
|
|
flag: "r",
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
quoteData.quotes.forEach((quote) => {
|
|
|
|
quote.length = quote.text.length;
|
|
|
|
});
|
|
|
|
|
|
|
|
fs.writeFileSync(
|
|
|
|
`../static/quotes/${quotefilename}.json`,
|
|
|
|
JSON.stringify(quoteData, null, 2)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
fixQuoteLengths();
|