Hello!
Thanks for library!
How can I ignore all directories(directory1 and directory2) and watching only files(file1 and file2) in directory root?
e.g.
var chokidar = require('chokidar');
var fs = require('fs');
chokidar.watch('./root', {
ignoreDirectories: true
}).on('all', (event, path) => {
console.log(event, path);
});
Best regards!
Found answers by myself :)
1.
var chokidar = require('chokidar');
var fs = require('fs');
chokidar.watch('./root', {
alwaysStat: true
}).on('all', (event, path, stats) => {
console.log(event, path, stats);
console.log(`${path} is directory:`, stats.isDirectory());
});
2.
var chokidar = require('chokidar');
var fs = require('fs');
chokidar.watch('./root', {
ignored: (path, stats) => {
return stats && stats.isDirectory();
}
}).on('all', (event, path) => {
console.log(event, path);
});
Please add more examples.
Thanks for library :)
Most helpful comment
Found answers by myself :)
Does the path is directory or file?
1.
Watch only files and ignore directories.
2.
Please add more examples.
Thanks for library :)