chore: Build at start

This commit is contained in:
Sidharth Vinod
2023-08-13 20:21:43 +05:30
parent fc99d9be41
commit 170bbce0d3

View File

@@ -20,7 +20,9 @@ const zenumlCtx = await context(
const contexts = [mermaidCtx, mermaidIIFECtx, externalCtx, zenumlCtx]; const contexts = [mermaidCtx, mermaidIIFECtx, externalCtx, zenumlCtx];
const rebuildAll = async () => { const rebuildAll = async () => {
const time = Date.now();
await Promise.all(contexts.map((ctx) => ctx.rebuild())); await Promise.all(contexts.map((ctx) => ctx.rebuild()));
console.log('Rebuilt in' + (Date.now() - time) + 'ms');
}; };
let clients: { id: number; response: Response }[] = []; let clients: { id: number; response: Response }[] = [];
@@ -51,10 +53,8 @@ function handleFileChange() {
clearTimeout(timeoutId); clearTimeout(timeoutId);
} }
timeoutId = setTimeout(async () => { timeoutId = setTimeout(async () => {
const time = Date.now();
await rebuildAll(); await rebuildAll();
sendEventsToAll(); sendEventsToAll();
console.log('Rebuild & Refresh complete in' + (Date.now() - time) + 'ms');
timeoutId = undefined; timeoutId = undefined;
}, 100); }, 100);
} }
@@ -64,6 +64,7 @@ function sendEventsToAll() {
} }
async function createServer() { async function createServer() {
await rebuildAll();
const app = express(); const app = express();
chokidar chokidar
.watch('**/src/**/*.{js,ts,yaml,json}', { .watch('**/src/**/*.{js,ts,yaml,json}', {