mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-09-12 09:37:29 +08:00
added script
This commit is contained in:
parent
bbff25bfbd
commit
675b7c1bf3
1 changed files with 58 additions and 0 deletions
58
frontend/scripts/fill-colors.js
Normal file
58
frontend/scripts/fill-colors.js
Normal file
|
@ -0,0 +1,58 @@
|
|||
const fs = require("fs");
|
||||
|
||||
function main() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const listFile = JSON.parse(
|
||||
fs.readFileSync("../static/themes/_list.json", {
|
||||
encoding: "utf8",
|
||||
})
|
||||
);
|
||||
const themeFiles = fs.readdirSync("../static/themes/");
|
||||
// themeFiles.forEach((filename) => {
|
||||
for (let filename of themeFiles) {
|
||||
if (filename === "_list.json") continue;
|
||||
|
||||
filename = filename.split(".")[0];
|
||||
let themeData = fs.readFileSync(`../static/themes/${filename}.css`, {
|
||||
encoding: "utf8",
|
||||
flag: "r",
|
||||
});
|
||||
|
||||
const subMatches = /--sub-color: (#.+);/g.exec(themeData);
|
||||
|
||||
const bgMatches = /--bg-color: (#.+);/g.exec(themeData);
|
||||
|
||||
const mainMatches = /--main-color: (#.+);/g.exec(themeData);
|
||||
|
||||
const textMatches = /--text-color: (#.+);/g.exec(themeData);
|
||||
|
||||
listFile.find(
|
||||
(theme) => theme.name === filename.split(".css")[0]
|
||||
).subColor = subMatches[1];
|
||||
listFile.find(
|
||||
(theme) => theme.name === filename.split(".css")[0]
|
||||
).textColor = textMatches[1];
|
||||
listFile.find(
|
||||
(theme) => theme.name === filename.split(".css")[0]
|
||||
).bgColor = bgMatches[1];
|
||||
listFile.find(
|
||||
(theme) => theme.name === filename.split(".css")[0]
|
||||
).mainColor = mainMatches[1];
|
||||
|
||||
// console.log(themeData);
|
||||
|
||||
// fs.writeFileSync(
|
||||
// `../static/quotes/${filename}.json`,
|
||||
// JSON.stringify(quoteData, null, 2)
|
||||
// );
|
||||
}
|
||||
fs.writeFileSync(
|
||||
`../static/themes/_list.json`,
|
||||
JSON.stringify(listFile, null, 2)
|
||||
);
|
||||
resolve();
|
||||
});
|
||||
// });
|
||||
}
|
||||
|
||||
main();
|
Loading…
Add table
Reference in a new issue