monkeytype/frontend/scripts/fix-quote-lengths.js
Sanidhya Singh 9aeaa31d2c
impr: replace JSONSchema with ajv for faster validation (sanidhyas3s) (#5145)
* impr: replace JSONSchema with ajv for faster validation

* Remove JSONSchema from packages

* Add ajv in dev-dependencies

* move dep to frontend

* Fix validation schema for different languages and error messages

* fix double space

* different way of showing errors

* por que no los dos

* return on failed schema

---------

Co-authored-by: Miodec <jack@monkeytype.com>
2024-03-11 20:00:10 +01:00

28 lines
695 B
JavaScript

const fs = require("fs");
function fixQuoteLengths() {
return new Promise((resolve) => {
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();