mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Compare commits
10 Commits
quick-add-
...
fix-link-t
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24178beafc | ||
|
|
6044871438 | ||
|
|
e612bb6a38 | ||
|
|
81ea67d6da | ||
|
|
892d21fb77 | ||
|
|
95a7980ada | ||
|
|
281e9d1357 | ||
|
|
742f05f59d | ||
|
|
79db4f8aa1 | ||
|
|
f4d7b71984 |
4
.github/workflows/tests.yml
vendored
4
.github/workflows/tests.yml
vendored
@@ -19,9 +19,9 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
node-version: [14, 16]
|
node-version: [14, 16]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
|
|||||||
@@ -117,7 +117,9 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
if (typeof data === "boolean") { data = data.toString(); }
|
if (typeof data === "boolean") { data = data.toString(); }
|
||||||
if (typeof data === "number") { data = data.toString(); }
|
if (typeof data === "number") { data = data.toString(); }
|
||||||
if ((node.appendNewline) && (!Buffer.isBuffer(data))) { data += os.EOL; }
|
var aflg = true;
|
||||||
|
if (msg.hasOwnProperty("parts") && msg.parts.type === "string" && (msg.parts.count === msg.parts.index + 1)) { aflg = false; }
|
||||||
|
if ((node.appendNewline) && (!Buffer.isBuffer(data)) && aflg) { data += os.EOL; }
|
||||||
var buf;
|
var buf;
|
||||||
if (node.encoding === "setbymsg") {
|
if (node.encoding === "setbymsg") {
|
||||||
buf = encode(data, msg.encoding || "none");
|
buf = encode(data, msg.encoding || "none");
|
||||||
@@ -314,7 +316,6 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
filename = filename || "";
|
filename = filename || "";
|
||||||
var fullFilename = filename;
|
var fullFilename = filename;
|
||||||
var filePath = "";
|
|
||||||
if (filename && RED.settings.fileWorkingDirectory && !path.isAbsolute(filename)) {
|
if (filename && RED.settings.fileWorkingDirectory && !path.isAbsolute(filename)) {
|
||||||
fullFilename = path.resolve(path.join(RED.settings.fileWorkingDirectory,filename));
|
fullFilename = path.resolve(path.join(RED.settings.fileWorkingDirectory,filename));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -818,6 +818,16 @@ function handlePreRoute(flow, sendEvent, reportError) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deliverMessageToDestination(sendEvent) {
|
||||||
|
if (sendEvent?.destination?.node) {
|
||||||
|
try {
|
||||||
|
sendEvent.destination.node.receive(sendEvent.msg);
|
||||||
|
} catch(err) {
|
||||||
|
Log.error(`Error delivering message to node:${sendEvent.destination.node._path} [${sendEvent.destination.node.type}]`)
|
||||||
|
Log.error(err.stack)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
function handlePreDeliver(flow,sendEvent, reportError) {
|
function handlePreDeliver(flow,sendEvent, reportError) {
|
||||||
// preDeliver - the local router has identified the node it is going to send to. At this point, the message has been cloned if needed.
|
// preDeliver - the local router has identified the node it is going to send to. At this point, the message has been cloned if needed.
|
||||||
hooks.trigger("preDeliver",sendEvent,(err) => {
|
hooks.trigger("preDeliver",sendEvent,(err) => {
|
||||||
@@ -827,15 +837,10 @@ function handlePreDeliver(flow,sendEvent, reportError) {
|
|||||||
} else if (err !== false) {
|
} else if (err !== false) {
|
||||||
if (asyncMessageDelivery) {
|
if (asyncMessageDelivery) {
|
||||||
setImmediate(function() {
|
setImmediate(function() {
|
||||||
if (sendEvent.destination.node) {
|
deliverMessageToDestination(sendEvent)
|
||||||
sendEvent.destination.node.receive(sendEvent.msg);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if (sendEvent.destination.node) {
|
deliverMessageToDestination(sendEvent)
|
||||||
sendEvent.destination.node.receive(sendEvent.msg);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// postDeliver - the message has been dispatched to be delivered asynchronously (unless the sync delivery flag is set, in which case it would be continue as synchronous delivery)
|
// postDeliver - the message has been dispatched to be delivered asynchronously (unless the sync delivery flag is set, in which case it would be continue as synchronous delivery)
|
||||||
hooks.trigger("postDeliver", sendEvent, function(err) {
|
hooks.trigger("postDeliver", sendEvent, function(err) {
|
||||||
|
|||||||
2
packages/node_modules/node-red/red.js
vendored
2
packages/node_modules/node-red/red.js
vendored
@@ -458,7 +458,7 @@ httpsPromise.then(function(startupHttps) {
|
|||||||
RED.start().then(function() {
|
RED.start().then(function() {
|
||||||
if (settings.httpAdminRoot !== false || settings.httpNodeRoot !== false || settings.httpStatic) {
|
if (settings.httpAdminRoot !== false || settings.httpNodeRoot !== false || settings.httpStatic) {
|
||||||
server.on('error', function(err) {
|
server.on('error', function(err) {
|
||||||
if (err.errno === "EADDRINUSE") {
|
if (err.code === "EADDRINUSE") {
|
||||||
RED.log.error(RED.log._("server.unable-to-listen", {listenpath:getListenPath()}));
|
RED.log.error(RED.log._("server.unable-to-listen", {listenpath:getListenPath()}));
|
||||||
RED.log.error(RED.log._("server.port-in-use"));
|
RED.log.error(RED.log._("server.port-in-use"));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
2
packages/node_modules/node-red/settings.js
vendored
2
packages/node_modules/node-red/settings.js
vendored
@@ -416,7 +416,7 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
// theme: "vs",
|
// theme: "vs",
|
||||||
/** other overrides can be set e.g. fontSize, fontFamily, fontLigatures etc.
|
/** other overrides can be set e.g. fontSize, fontFamily, fontLigatures etc.
|
||||||
* for the full list, see https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.IStandaloneEditorConstructionOptions.html
|
* for the full list, see https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IStandaloneEditorConstructionOptions.html
|
||||||
*/
|
*/
|
||||||
//fontSize: 14,
|
//fontSize: 14,
|
||||||
//fontFamily: "Cascadia Code, Fira Code, Consolas, 'Courier New', monospace",
|
//fontFamily: "Cascadia Code, Fira Code, Consolas, 'Courier New', monospace",
|
||||||
|
|||||||
@@ -194,6 +194,55 @@ describe('file Nodes', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should append to a file and add newline, except last line of multipart input', function(done) {
|
||||||
|
var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":true, "overwriteFile":false, wires: [["helperNode1"]]},
|
||||||
|
{id:"helperNode1", type:"helper"}];
|
||||||
|
try {
|
||||||
|
fs.unlinkSync(fileToTest);
|
||||||
|
} catch(err) {
|
||||||
|
}
|
||||||
|
helper.load(fileNode, flow, function() {
|
||||||
|
var n1 = helper.getNode("fileNode1");
|
||||||
|
var n2 = helper.getNode("helperNode1");
|
||||||
|
var count = 0;
|
||||||
|
//var data = ["Line1", "Line2"];
|
||||||
|
|
||||||
|
n2.on("input", function (msg) {
|
||||||
|
try {
|
||||||
|
msg.should.have.property("payload");
|
||||||
|
//data.should.containDeep([msg.payload]);
|
||||||
|
if (count === 3) {
|
||||||
|
var f = fs.readFileSync(fileToTest).toString();
|
||||||
|
if (os.type() !== "Windows_NT") {
|
||||||
|
f.should.have.length(23);
|
||||||
|
f.should.equal("Line1\nLine2\nLine3\nLine4");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
f.should.have.length(23);
|
||||||
|
f.should.equal("Line1\r\nLine2\r\nLine3\r\nLine4");
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
done(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
n1.receive({payload:"Line1",parts:{index:0,type:"string"}}); // string
|
||||||
|
setTimeout(function() {
|
||||||
|
n1.receive({payload:"Line2",parts:{index:1,type:"string"}}); // string
|
||||||
|
},30);
|
||||||
|
setTimeout(function() {
|
||||||
|
n1.receive({payload:"Line3",parts:{index:2,type:"string"}}); // string
|
||||||
|
},60);
|
||||||
|
setTimeout(function() {
|
||||||
|
n1.receive({payload:"Line4",parts:{index:3,type:"string",count:4}}); // string
|
||||||
|
},90);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should append to a file after it has been deleted ', function(done) {
|
it('should append to a file after it has been deleted ', function(done) {
|
||||||
var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":false, "overwriteFile":false, wires: [["helperNode1"]]},
|
var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":false, "overwriteFile":false, wires: [["helperNode1"]]},
|
||||||
{id:"helperNode1", type:"helper"}];
|
{id:"helperNode1", type:"helper"}];
|
||||||
|
|||||||
Reference in New Issue
Block a user