mirror of
https://github.com/remko/waforth
synced 2025-01-31 19:57:43 +01:00
build: Clean up build
This commit is contained in:
parent
01fcb9e2a8
commit
59b56e5491
1 changed files with 16 additions and 28 deletions
44
build-web.js
44
build-web.js
|
@ -113,35 +113,23 @@ const INDEX_TEMPLATE = `<!doctype html>
|
||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
async function handleBuildFinished(result) {
|
async function handleBuildFinished(result) {
|
||||||
let index = INDEX_TEMPLATE.replace(/\$BASE/g, "shell");
|
const indexes = [
|
||||||
let testIndex = INDEX_TEMPLATE.replace(/\$BASE/g, "tests");
|
["shell", "public/waforth"],
|
||||||
let benchmarksIndex = INDEX_TEMPLATE.replace(/\$BASE/g, "benchmarks");
|
["tests", "public/waforth/tests"],
|
||||||
let promptIndex = INDEX_TEMPLATE.replace(/\$BASE/g, "prompt");
|
["benchmarks", "public/waforth/benchmarks"],
|
||||||
// console.log(JSON.stringify(result.metafile.outputs, undefined, 2));
|
["prompt", "public/waforth/examples/prompt"],
|
||||||
for (const [out] of Object.entries(result.metafile.outputs)) {
|
];
|
||||||
const outfile = path.basename(out);
|
for (const [base, outpath] of indexes) {
|
||||||
const sourcefile = outfile.replace(/-c\$[^.]+\./, ".");
|
let index = INDEX_TEMPLATE.replace(/\$BASE/g, base);
|
||||||
// console.log("%s -> %s", sourcefile, outfile);
|
for (const [out] of Object.entries(result.metafile.outputs)) {
|
||||||
index = index.replace(`/${sourcefile}`, `/${outfile}`);
|
const outfile = path.basename(out);
|
||||||
testIndex = testIndex.replace(`/${sourcefile}`, `/${outfile}`);
|
const sourcefile = outfile.replace(/-c\$[^.]+\./, ".");
|
||||||
benchmarksIndex = benchmarksIndex.replace(`/${sourcefile}`, `/${outfile}`);
|
// console.log("%s -> %s", sourcefile, outfile);
|
||||||
promptIndex = promptIndex.replace(`/${sourcefile}`, `/${outfile}`);
|
index = index.replace(`/${sourcefile}`, `/${outfile}`);
|
||||||
|
}
|
||||||
|
await fs.promises.mkdir(outpath, { recursive: true });
|
||||||
|
await fs.promises.writeFile(path.join(outpath, "index.html"), index);
|
||||||
}
|
}
|
||||||
await fs.promises.writeFile("public/waforth/index.html", index);
|
|
||||||
await fs.promises.mkdir("public/waforth/tests", { recursive: true });
|
|
||||||
await fs.promises.writeFile("public/waforth/tests/index.html", testIndex);
|
|
||||||
await fs.promises.mkdir("public/waforth/benchmarks", { recursive: true });
|
|
||||||
await fs.promises.writeFile(
|
|
||||||
"public/waforth/benchmarks/index.html",
|
|
||||||
benchmarksIndex
|
|
||||||
);
|
|
||||||
await fs.promises.mkdir("public/waforth/examples/prompt", {
|
|
||||||
recursive: true,
|
|
||||||
});
|
|
||||||
await fs.promises.writeFile(
|
|
||||||
"public/waforth/examples/prompt/index.html",
|
|
||||||
promptIndex
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (watch) {
|
if (watch) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue