Is there any way to ignore multiple files or directories when watching directory with Chokidar?
My code:
var ignoredFiles = ['c:/test/file1.txt', 'c:/test/file2.txt'];
//var ignoredFiles = 'c:/test/file1.txt';
var watchOptions: WatchOptions = <WatchOptions>{
ignored: ignoredFiles,
persistent: true,
ignoreInitial: false,
awaitWriteFinish: false,
ignorePermissionErrors: false
};
this.watcher = chokidar.watch('c:/test', watchOptions);
If I try to set ignored option to array of strings, it doesn't work. Moreover, even if I try to set it to string, it doesn't work either.
Any suggestions about a simple way of doing that? From Chokidar docs:
ignored: (anymatch-compatible definition) Defines files/paths to be ignored. The whole relative or absolute path is tested, not just filename. If a function with two arguments is provided, it gets called twice per path - once with a single argument (the path), second time with two arguments (the path and the fs.Stats object of that path).
Thank you.
Various options for ignored
var ignoredFiles = ['c:/test/file1.txt', 'c:/test/file2.txt'];
var watchOptions = {
ignored: ignoredFiles,
persistent: true,
ignoreInitial: false,
awaitWriteFinish: false,
ignorePermissionErrors: false
};
this.watcher = chokidar.watch('c:/test', watchOptions);
or else
ignored: /file/, // ignores files and dirs which contain "file" in the name
You can also use regular expressions
ignored: /file[1-2]\.txt/, // ignores files matching this regex
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.