Update tail node to accept/display regex.

To address Issue #555
This commit is contained in:
Dave Conway-Jones 2019-07-12 12:22:13 +01:00
parent 6030b45735
commit 55698e637d
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
4 changed files with 8 additions and 9 deletions

View File

@ -25,8 +25,8 @@
</script> </script>
<script type="text/x-red" data-help-name="tail"> <script type="text/x-red" data-help-name="tail">
<p>Tails (watches for things to be added) to the configured file. (Linux/Mac ONLY)</p> <p>Tails (watches for things to be added) to the configured file.</p>
<p>This will not work on Windows filesystems, as it relies on the <b>tail -F</b> command.</p> <p>Note: On Windows you may need to close the file between writes for any updates to be registered.</p>
<h3>Outputs</h3> <h3>Outputs</h3>
<ul> <ul>
<li>Text (UTF-8) files will be returned as strings.</li> <li>Text (UTF-8) files will be returned as strings.</li>
@ -40,7 +40,7 @@
defaults: { defaults: {
name: {value:""}, name: {value:""},
filetype: {value:"text"}, filetype: {value:"text"},
split: {value:"[\r]{0,1}\n"}, split: {value:"[\\r]{0,1}\\n"},
filename: {value:"",required:true} filename: {value:"",required:true}
}, },
color:"BurlyWood", color:"BurlyWood",

View File

@ -9,7 +9,7 @@ module.exports = function(RED) {
this.filename = n.filename; this.filename = n.filename;
this.filetype = n.filetype || "text"; this.filetype = n.filetype || "text";
this.split = new RegExp(n.split || "[\r]{0,1}\n"); this.split = new RegExp(n.split.replace(/\\r/g,'\r').replace(/\\n/g,'\n').replace(/\\t/g,'\t') || "[\r]{0,1}\n");
var node = this; var node = this;
var fileTail = function() { var fileTail = function() {
@ -42,7 +42,7 @@ module.exports = function(RED) {
} }
else { else {
node.tout = setTimeout(function() { fileTail(); },10000); node.tout = setTimeout(function() { fileTail(); },10000);
node.warn(RED._("tail.errors.filenotfound") + node.filename); node.warn(RED._("tail.errors.filenotfound") + ": "+node.filename);
} }
} }

View File

@ -15,8 +15,7 @@
--> -->
<script type="text/x-red" data-help-name="tail"> <script type="text/x-red" data-help-name="tail">
<p>設定したファイルの末尾を出力(追加されたデータを監視)します。(Linux/Macのみ)</p> <p>設定したファイルの末尾を出力(追加されたデータを監視)します.</p>
<p>このノードは<b>tail -F</b>コマンドを内部で利用しているため、Windowsファイルシステムでは動作しません。</p>
<h3>出力</h3> <h3>出力</h3>
<ul> <ul>
<li>(UTF-8形式の)テキストファイルは文字列を返却。</li> <li>(UTF-8形式の)テキストファイルは文字列を返却。</li>

View File

@ -1,9 +1,9 @@
{ {
"name": "node-red-node-tail", "name": "node-red-node-tail",
"version": "0.0.2", "version": "0.0.3",
"description": "A node to tail files for Node-RED", "description": "A node to tail files for Node-RED",
"dependencies": { "dependencies": {
"tail": "^2.0.0" "tail": "^2.0.2"
}, },
"repository": { "repository": {
"type": "git", "type": "git",