admin管理员组文章数量:1123184
I am trying to set up a script that watches for new folders that are added to a directory called /test
.
I am using Chokidar to watch for folder changes. The problem is, it fires an event for the folder it is supposed to be watching.
The script looks like this
import chokidar from "chokidar";
const watchDirectory = async () => {
const watcher = chokidar.watch('./test');
watcher
.on("addDir", (dirPath) => {
const dirName = path.basename(dirPath);
console.log(`Detected new folder: ${dirName}`); // logs: Detected new folder: test
})
};
watchDirectory();
the addDir
event callback runs and thinks that /test
has just been added. But /test
is the name of the folder I am watching.
How do I get Chokidar to ignore /test
and just watch for new folders that are added to the test /test
path?
本文标签: javascriptHow to stop chokidar from triggering on root folder it39s watchingStack Overflow
版权声明:本文标题:javascript - How to stop chokidar from triggering on root folder it's watching? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736555161a1944566.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论