37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { articles } from "../lib/tasks/articles.js";
|
|
import { css } from "../lib/tasks.js";
|
|
import { fonts } from "../lib/tasks.js";
|
|
import { images } from "../lib/tasks.js";
|
|
import { svg } from "../lib/tasks.js";
|
|
|
|
import { argv, exit } from "node:process";
|
|
|
|
const wrapTask = (name: string, task: () => Promise<void>) => async () => {
|
|
console.log("[start]", name);
|
|
await task();
|
|
console.log("[end]", name);
|
|
};
|
|
|
|
const TASKS = {
|
|
all: wrapTask("all", () => fonts().then(images).then(svg).then(css).then(articles)),
|
|
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);
|
|
await (args.length ? args : ALL_TASKS)
|
|
.map((task) => {
|
|
if (!TASKS.hasOwnProperty(task)) {
|
|
console.error("Unknown task", task);
|
|
exit(1);
|
|
}
|
|
|
|
return TASKS[task];
|
|
})
|
|
.reduce((prev, cur) => prev.then(cur), Promise.resolve());
|