Add timeout to watcher
This commit is contained in:
+10
-2
@@ -5,6 +5,10 @@ const path = require("path");
|
||||
const { execSync } = require("child_process");
|
||||
const delay = require("../../utils/delay");
|
||||
|
||||
/** @type {any} */
|
||||
let timeout;
|
||||
const UPDATE_TIMEOUT = 5000;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {SyncFoldersFnParams} param0
|
||||
@@ -82,8 +86,12 @@ async function watchFolders({ folders, options }) {
|
||||
await delay();
|
||||
|
||||
fs.watch(dirPath, { recursive: true }, (evt, fileName) => {
|
||||
sync({ dirPath, dirs, options });
|
||||
process.exit(1);
|
||||
clearTimeout(timeout);
|
||||
|
||||
timeout = setTimeout(() => {
|
||||
sync({ dirPath, dirs, options });
|
||||
process.exit(1);
|
||||
}, UPDATE_TIMEOUT);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user