zed/styles/src/buildThemes.ts

24 lines
702 B
TypeScript
Raw Normal View History

import * as fs from "fs";
import * as path from "path";
2022-04-02 03:58:04 +00:00
import app from "./styleTree/app";
import themes from "./themes";
import snakeCase from "./utils/snakeCase";
const themeDirectory = `${__dirname}/../../assets/themes/`;
// Clear existing themes
for (const file of fs.readdirSync(themeDirectory)) {
fs.unlinkSync(path.join(themeDirectory, file));
}
// Write new themes to theme directory
for (let theme of themes) {
2022-04-06 17:35:29 +00:00
let styleTree = snakeCase(app(theme));
let styleTreeJSON = JSON.stringify(styleTree, null, 2);
let outPath = path.resolve(
`${__dirname}/../../assets/themes/${theme.name}.json`
2022-04-06 17:35:29 +00:00
);
fs.writeFileSync(outPath, styleTreeJSON);
console.log(`- ${outPath} created`);
}