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",
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];
if (cdoc) {
const doc = cdoc.build["site"];
@ -200,8 +207,8 @@ if (typeof global.server_hook === "function") {
if (esbuild) {
try {
await esbuild.rebuild();
} catch (e) {
console.error(e);
} catch (e: any) {
await codeError(id_site, e.message, mode);
}
}
@ -236,3 +243,18 @@ const codeApplyChanges = (path: string, doc: DCode) => {
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);
};