This commit is contained in:
Rizky 2023-11-18 16:06:29 +07:00
parent c19505692a
commit 6e1ad373dd
2 changed files with 18 additions and 1 deletions

View File

@ -76,6 +76,7 @@ export const codeBuild = async (code: DBCode) => {
});
});
} catch (e: any) {
console.error(e);
activity.site
.room(code.id_site)
.findAll({ site_js: code.name })

View File

@ -33,7 +33,7 @@ export const startCodeWatcher = async (code: DBCode) => {
let delay = false;
const indexes = {} as Record<string, (typeof code)["code_file"][0]>;
if (code.code_file.length === 0) {
if (!code.code_file.find((e) => e.path === "package.json")) {
code.code_file.push(
await db.code_file.create({
data: {
@ -45,6 +45,20 @@ export const startCodeWatcher = async (code: DBCode) => {
);
}
if (!code.code_file.find((e) => e.path === "index.tsx")) {
let content = `export const hello = 'world';`;
code.code_file.push(
await db.code_file.create({
data: {
id_code: code.id,
path: "index.tsx",
content,
},
})
);
}
for (const c of code.code_file) {
const path = Code.path(c.id_code, c.path);
@ -67,6 +81,8 @@ export const startCodeWatcher = async (code: DBCode) => {
stderr: "ignore",
stdout: "ignore",
}).exited;
await codeBuild(code);
Code.watchers[code.id] = {
id: code.id,