From c7404a9d4cbe9e46e3b04f754559d0574ca1d587 Mon Sep 17 00:00:00 2001 From: Wenderson Pires Date: Mon, 29 Apr 2024 16:49:50 -0300 Subject: [PATCH] fix file change detector --- lib/dev.js | 23 ++++++----------------- package.json | 2 +- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/lib/dev.js b/lib/dev.js index 5f5b9a2..f359a70 100644 --- a/lib/dev.js +++ b/lib/dev.js @@ -47,7 +47,12 @@ async function dev(opts) { process.exit(1); }); - const onChangeDetectHandler = async () => { + watchFolders(["./src"], async (path) => { + loading = log.loading(`Change detected in ${path}, rebuilding...`); + + // Atualiza o arquivo no cache para ser acessado posteriormente no re-build() + filesContentCache.updateFileContent(path); + await build(opts).catch((err) => { loading.error(); log.error(err); @@ -59,22 +64,6 @@ async function dev(opts) { io.emit("fileChange", devJson); } // loading.finish(); - }; - - let debounceInterval = null; - watchFolders(["./src"], async (path) => { - log.info(`Change detected in ${path}, rebuilding...`); - - // Atualiza o arquivo no cache para ser acessado posteriormente no re-build() - filesContentCache.updateFileContent(path); - - if (debounceInterval) { - clearInterval(debounceInterval); - } - debounceInterval = setInterval(() => { - clearInterval(debounceInterval); - onChangeDetectHandler(); - }, 200); }); setTimeout(() => { diff --git a/package.json b/package.json index e8e216f..043ba59 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "alem", "description": "Create web3 applications for NEAR BOS with a focus on performance and friendly development.", - "version": "1.0.0-beta.33", + "version": "1.0.0-beta.34", "main": "main.js", "types": "index.d.ts", "author": "Wenderson Pires - wendersonpires.near",