Skip to content

Commit 16e1795

Browse files
author
dceejay
committed
add try catch to helper shutdown,
tiny fixes for exec and trigger based on tests
1 parent cc1d080 commit 16e1795

3 files changed

Lines changed: 17 additions & 14 deletions

File tree

nodes/core/core/75-exec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ module.exports = function(RED) {
2222

2323
function ExecNode(n) {
2424
RED.nodes.createNode(this,n);
25-
this.cmd = n.command.trim();
25+
this.cmd = (n.command || "").trim();
2626
this.addpay = n.addpay;
27-
this.append = n.append.trim() || "";
27+
this.append = (n.append || "").trim();
2828
this.useSpawn = n.useSpawn;
2929

3030
var node = this;
@@ -33,7 +33,7 @@ module.exports = function(RED) {
3333
if (this.useSpawn === true) {
3434
// make the extra args into an array
3535
// then prepend with the msg.payload
36-
if (typeof(msg.payload !== "string")) { msg.payload = msg.payload.toString(); }
36+
if (typeof(msg.payload !== "string")) { msg.payload = (msg.payload || "").toString(); }
3737
var arg = [];
3838
if (node.append.length > 0) { arg = node.append.split(","); }
3939
if ((node.addpay === true) && (msg.payload.trim() !== "")) { arg.unshift(msg.payload); }

nodes/core/core/89-trigger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = function(RED) {
2323
this.op2 = n.op2 || "0";
2424
this.op1type = n.op1type || "val";
2525
this.op2type = n.op2type || "val";
26-
this.extend = n.extend || false;
26+
this.extend = n.extend || "false";
2727
this.units = n.units || "ms";
2828
this.duration = n.duration || 250;
2929
if (this.duration <= 0) { this.duration = 0; }

test/nodes/helper.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ module.exports = {
5656
logSpy = sinon.spy(log,"log");
5757
logSpy.FATAL = log.FATAL;
5858
logSpy.ERROR = log.ERROR;
59-
logSpy.WARN = log.WARN;
60-
logSpy.INFO = log.INFO;
61-
logSpy.DEBUG = log.DEBUG;
62-
logSpy.TRACE = log.TRACE;
63-
logSpy.METRIC = log.METRIC;
64-
59+
logSpy.WARN = log.WARN;
60+
logSpy.INFO = log.INFO;
61+
logSpy.DEBUG = log.DEBUG;
62+
logSpy.TRACE = log.TRACE;
63+
logSpy.METRIC = log.METRIC;
64+
6565
if (typeof testCredentials === 'function') {
6666
cb = testCredentials;
6767
testCredentials = {};
@@ -94,7 +94,7 @@ module.exports = {
9494
testNode[i](RED);
9595
}
9696
} else {
97-
testNode(RED);
97+
testNode(RED);
9898
}
9999
flows.load().then(function() {
100100
should.deepEqual(testFlows, flows.getFlows());
@@ -138,14 +138,17 @@ module.exports = {
138138
//TODO consider saving TCP handshake/server reinit on start/stop/start sequences
139139
stopServer: function(done) {
140140
if(server) {
141-
server.close(done);
141+
try {
142+
server.close(done);
143+
} catch(e) {
144+
done();
145+
}
142146
}
143147
},
144148

145149
url: function() { return url; },
146150

147151
nock: nock,
148-
152+
149153
log: function() { return logSpy;}
150154
};
151-

0 commit comments

Comments
 (0)