web_lib

Common web application libraries
git clone https://radroots.dev/git/web_lib.git
Log | Files | Refs | LICENSE

handle-css-themes.ts (765B)


      1 import fs from "node:fs";
      2 import path from "node:path";
      3 import { build_themes_css_by_preset } from "../../generator/themes_css.js";
      4 import type { ThemesArgs } from "./main.js";
      5 
      6 export const handle_css_themes = async (args: ThemesArgs): Promise<void> => {
      7     const trimmed_dir = args.dir_out.trim();
      8     if (trimmed_dir.length === 0) {
      9         throw new Error("dir_out cannot be empty");
     10     }
     11 
     12     const output_dir = path.resolve(process.cwd(), trimmed_dir);
     13     fs.mkdirSync(output_dir, { recursive: true });
     14 
     15     const css_by_preset = build_themes_css_by_preset(args.presets);
     16     const css = Object.values(css_by_preset).join("\n");
     17     const output_path = path.join(output_dir, "themes.css");
     18 
     19     fs.writeFileSync(output_path, css, { encoding: "utf8" });
     20 };