mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Catch more errors in file watcher node.
This commit is contained in:
parent
a4d27e4cb5
commit
8c8f75df69
@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
<script type="text/x-red" data-template-name="watch">
|
<script type="text/x-red" data-template-name="watch">
|
||||||
<div class="form-row node-input-filename">
|
<div class="form-row node-input-filename">
|
||||||
<label for="node-input-files"><i class="icon-file"></i> File(s)</label>
|
<label for="node-input-files"><i class="fa fa-file"></i> File(s)</label>
|
||||||
<input type="text" id="node-input-files" placeholder="File(s) or Directory">
|
<input type="text" id="node-input-files" placeholder="File(s) or Directory">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
||||||
<input type="text" id="node-input-name" placeholder="Name">
|
<input type="text" id="node-input-name" placeholder="Name">
|
||||||
</div>
|
</div>
|
||||||
<div id="node-input-tip" class="form-tips">On Windows you must use double slashes \\ in any directory names.</div>
|
<div id="node-input-tip" class="form-tips">On Windows you must use double slashes \\ in any directory names.</div>
|
||||||
|
@ -29,13 +29,20 @@ 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);
|
||||||
var node = this;
|
var node = this;
|
||||||
|
|
||||||
var notifications = new notify(node.files);
|
var notifications = new notify(node.files);
|
||||||
notifications.on('change', function (file, event, path) {
|
notifications.on('change', function (file, event, path) {
|
||||||
|
try {
|
||||||
if (fs.statSync(path).isDirectory()) { path = path + sep + file; }
|
if (fs.statSync(path).isDirectory()) { path = path + sep + file; }
|
||||||
|
} catch(e) { }
|
||||||
var msg = { payload: path, topic: node.p, file: file };
|
var msg = { payload: path, topic: node.p, file: file };
|
||||||
node.send(msg);
|
node.send(msg);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
notifications.on('error', function (error, path) {
|
||||||
|
node.warn(error);
|
||||||
|
});
|
||||||
|
|
||||||
this.close = function() {
|
this.close = function() {
|
||||||
notifications.close();
|
notifications.close();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user