This commit is contained in:
Rizky 2024-03-16 14:19:32 +07:00
parent 1878edf68c
commit b9a112b9b2
2 changed files with 53 additions and 31 deletions

File diff suppressed because one or more lines are too long

View File

@ -176,7 +176,14 @@ if (typeof global.server_hook === "function") {
{ {
name: "prasi", name: "prasi",
setup(setup) { setup(setup) {
setup.onEnd((res) => { setup.onEnd(async (res) => {
if (res.errors.length > 0) {
await codeError(
id_site,
res.errors.map((e) => e.text).join("\n\n"),
"site"
);
}
const cdoc = docs.code[id_site]; const cdoc = docs.code[id_site];
if (cdoc) { if (cdoc) {
const doc = cdoc.build["site"]; const doc = cdoc.build["site"];
@ -200,8 +207,8 @@ if (typeof global.server_hook === "function") {
if (esbuild) { if (esbuild) {
try { try {
await esbuild.rebuild(); await esbuild.rebuild();
} catch (e) { } catch (e: any) {
console.error(e); await codeError(id_site, e.message, mode);
} }
} }
@ -236,3 +243,18 @@ const codeApplyChanges = (path: string, doc: DCode) => {
return doc; return doc;
}; };
const codeError = async (
id_site: string,
error: string,
mode: "server" | "site"
) => {
const path = code.path(
id_site,
"site",
"build",
mode === "server" ? "server.log" : "error.log"
);
await Bun.write(path, error);
};