Own task runner
This commit is contained in:
parent
4bfecd462e
commit
334a0dd68d
35
bin/build.ts
35
bin/build.ts
|
@ -1,3 +1,36 @@
|
|||
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";
|
||||
|
||||
(async () => await articles())();
|
||||
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());
|
||||
|
|
|
@ -18,7 +18,7 @@ import { renderToStaticMarkup } from "preact-render-to-string";
|
|||
import { SITE_TITLE, SITE_DESCRIPTION } from "../constants.js";
|
||||
import { JSX } from "preact/jsx-runtime";
|
||||
import { reloadAssets } from "../assets.js";
|
||||
import { mergeMap, Observable, Subscriber } from "rxjs";
|
||||
import { lastValueFrom, mergeMap, Observable, Subscriber } from "rxjs";
|
||||
import { dest, fromGlob, onComplete } from "../rx-utils.js";
|
||||
|
||||
const Asciidoctor = asciidoctor();
|
||||
|
@ -119,8 +119,8 @@ export const articles = () => {
|
|||
reloadAssets();
|
||||
const articles = [];
|
||||
|
||||
return fromGlob("articles/**/*.asciidoc")
|
||||
.pipe(
|
||||
return lastValueFrom(
|
||||
fromGlob("articles/**/*.asciidoc").pipe(
|
||||
mergeMap(
|
||||
(file) =>
|
||||
new Observable<File>((subscriber) => {
|
||||
|
@ -131,6 +131,7 @@ export const articles = () => {
|
|||
}),
|
||||
),
|
||||
onComplete(finalizeArticles(articles)),
|
||||
)
|
||||
.forEach(dest("dist"));
|
||||
mergeMap(dest("dist")),
|
||||
),
|
||||
).then(() => {});
|
||||
};
|
||||
|
|
|
@ -23,4 +23,4 @@ export const css = () =>
|
|||
hashPaths("css.manifest"),
|
||||
mergeMap(dest("dist/_assets")),
|
||||
),
|
||||
);
|
||||
).then(() => {});
|
||||
|
|
Loading…
Reference in New Issue
Block a user