import { articles } from "../lib/tasks/articles.ts"; import { css } from "../lib/tasks/css.ts"; import { fonts } from "../lib/tasks/fonts.ts"; import { images } from "../lib/tasks/images.ts"; import { svg } from "../lib/tasks/svg.ts"; import { argv, exit } from "node:process"; const wrapTask = (name: string, task: () => Promise) => async () => { console.log("[start]", name); await task(); console.log("[end]", name); }; const TASKS: { [task: string]: () => Promise } = { articles: wrapTask("articles", articles), css: wrapTask("css", css), fonts: wrapTask("fonts", fonts), images: wrapTask("images", images), svg: wrapTask("svg", svg), }; const ALL_TASKS = ["fonts", "images", "svg", "css", "articles"]; const args = argv.slice(2); console.log("args", args); (args.length ? args : ALL_TASKS) .map((task: string) => { if (!TASKS.hasOwnProperty(task)) { console.error("Unknown task", task); exit(1); } return TASKS[task]; }) .reduce((prev: Promise, cur: () => Promise) => prev.then(cur), Promise.resolve());