1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #3569 from node-red/watch-fix

Fix Watch node handling of recursive directories
This commit is contained in:
Nick O'Leary 2022-05-03 09:22:31 +01:00 committed by GitHub
commit b74a42cdf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,7 +31,7 @@ module.exports = function(RED) {
this.p = (this.files.length === 1) ? this.files[0] : JSON.stringify(this.files); this.p = (this.files.length === 1) ? this.files[0] : JSON.stringify(this.files);
const node = this; const node = this;
const watcher = watch(this.files, { recursive: true }); const watcher = watch(this.files, { recursive: this.recursive });
watcher.on('change', function (event, fpath) { watcher.on('change', function (event, fpath) {
const file = path.basename(fpath) const file = path.basename(fpath)
@ -53,13 +53,7 @@ module.exports = function(RED) {
else if (stat.isCharacterDevice()) { type = "characterdevice"; } else if (stat.isCharacterDevice()) { type = "characterdevice"; }
else if (stat.isSocket()) { type = "socket"; } else if (stat.isSocket()) { type = "socket"; }
else if (stat.isFIFO()) { type = "fifo"; } else if (stat.isFIFO()) { type = "fifo"; }
else if (stat.isDirectory()) { else if (stat.isDirectory()) { type = "directory"; }
type = "directory";
if (node.recursive) {
notifications.add([fpath]);
notifications.add(getAllDirs(fpath));
}
}
else { type = "n/a"; } else { type = "n/a"; }
} }
msg.type = type; msg.type = type;