themes.ts

 1import fs from "fs";
 2import path from "path";
 3import Theme from "./themes/common/theme";
 4
 5const themes: Theme[] = [];
 6export default themes;
 7
 8const internalThemes: Theme[] = [];
 9export { internalThemes }
10
11const experimentalThemes: Theme[] = [];
12export { experimentalThemes }
13
14
15function fillThemes(themesPath: string, themes: Theme[]) {
16  for (const fileName of fs.readdirSync(themesPath)) {
17    if (fileName == "template.ts") continue;
18    const filePath = path.join(themesPath, fileName);
19
20    if (fs.statSync(filePath).isFile()) {
21      const theme = require(filePath);
22      if (theme.dark) themes.push(theme.dark);
23      if (theme.light) themes.push(theme.light);
24    }
25  }
26}
27
28fillThemes(path.resolve(`${__dirname}/themes`), themes)
29fillThemes(path.resolve(`${__dirname}/themes/internal`), internalThemes)
30fillThemes(path.resolve(`${__dirname}/themes/experiments`), experimentalThemes)
31