Merge pull request #5412 from kazuhitoyokoi/master-fixstatusnode

Fix status node to retrieve status from all nodes
pull/5401/head^2
Nick O'Leary 2026-01-05 17:28:24 +00:00 committed by GitHub
commit 8287a0aaab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 7 deletions

View File

@ -20,13 +20,15 @@ module.exports = function(RED) {
function StatusNode(n) {
RED.nodes.createNode(this,n);
var node = this;
this.scope = n.scope || [];
this.scope = n.scope;
// auto-filter out any directly connected nodes to avoid simple loopback
const w = this.wires.flat();
for (let i=0; i < this.scope.length; i++) {
if (w.includes(this.scope[i])) {
this.scope.splice(i, 1);
if (Array.isArray(this.scope)) {
const w = this.wires.flat();
for (let i = 0; i < this.scope.length; i++) {
if (w.includes(this.scope[i])) {
this.scope.splice(i, 1);
}
}
}

View File

@ -15,7 +15,7 @@
**/
var should = require("should");
var catchNode = require("nr-test-utils").require("@node-red/nodes/core/common/25-status.js");
var statusNode = require("nr-test-utils").require("@node-red/nodes/core/common/25-status.js");
var helper = require("node-red-node-test-helper");
describe('status Node', function() {
@ -27,7 +27,7 @@ describe('status Node', function() {
it('should output a message when called', function(done) {
var flow = [ { id:"n1", type:"status", name:"status", wires:[["n2"]], scope:[] },
{id:"n2", type:"helper"} ];
helper.load(catchNode, flow, function() {
helper.load(statusNode, flow, function() {
var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2");
n1.should.have.property('name', 'status');