buildThemes.ts

 1import * as fs from "fs";
 2import * as path from "path";
 3import app from "./styleTree/app";
 4import themes from "./themes";
 5import snakeCase from "./utils/snakeCase";
 6
 7const themeDirectory = `${__dirname}/../../assets/themes/`;
 8
 9// Clear existing themes
10for (const file of fs.readdirSync(themeDirectory)) {
11  fs.unlinkSync(path.join(themeDirectory, file));
12}
13
14// Write new themes to theme directory
15for (let theme of themes) {
16  let styleTree = snakeCase(app(theme));
17  let styleTreeJSON = JSON.stringify(styleTree, null, 2);
18  let outPath = path.resolve(
19    `${__dirname}/../../assets/themes/${theme.name}.json`
20  );
21  fs.writeFileSync(outPath, styleTreeJSON);
22  console.log(`- ${outPath} created`);
23}