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

View File

@ -9,7 +9,7 @@ module.exports = function(RED) {
this.filename = n.filename;
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 fileTail = function() {
@ -42,7 +42,7 @@ module.exports = function(RED) {
}
else {
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">
<p>設定したファイルの末尾を出力(追加されたデータを監視)します。(Linux/Macのみ)</p>
<p>このノードは<b>tail -F</b>コマンドを内部で利用しているため、Windowsファイルシステムでは動作しません。</p>
<p>設定したファイルの末尾を出力(追加されたデータを監視)します.</p>
<h3>出力</h3>
<ul>
<li>(UTF-8形式の)テキストファイルは文字列を返却。</li>

View File

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