Skip to content

Commit

Permalink
fix file change detector
Browse files Browse the repository at this point in the history
  • Loading branch information
wpdas committed Apr 29, 2024
1 parent eda0b8a commit c7404a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
23 changes: 6 additions & 17 deletions lib/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(() => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit c7404a9

Please sign in to comment.