1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

add try catch to helper shutdown,

tiny fixes for exec and trigger based on tests
This commit is contained in:
dceejay 2015-03-26 15:01:55 +00:00
parent cc1d080a5a
commit 16e17954b4
3 changed files with 17 additions and 14 deletions

View File

@ -22,9 +22,9 @@ module.exports = function(RED) {
function ExecNode(n) { function ExecNode(n) {
RED.nodes.createNode(this,n); RED.nodes.createNode(this,n);
this.cmd = n.command.trim(); this.cmd = (n.command || "").trim();
this.addpay = n.addpay; this.addpay = n.addpay;
this.append = n.append.trim() || ""; this.append = (n.append || "").trim();
this.useSpawn = n.useSpawn; this.useSpawn = n.useSpawn;
var node = this; var node = this;
@ -33,7 +33,7 @@ module.exports = function(RED) {
if (this.useSpawn === true) { if (this.useSpawn === true) {
// make the extra args into an array // make the extra args into an array
// then prepend with the msg.payload // then prepend with the msg.payload
if (typeof(msg.payload !== "string")) { msg.payload = msg.payload.toString(); } if (typeof(msg.payload !== "string")) { msg.payload = (msg.payload || "").toString(); }
var arg = []; var arg = [];
if (node.append.length > 0) { arg = node.append.split(","); } if (node.append.length > 0) { arg = node.append.split(","); }
if ((node.addpay === true) && (msg.payload.trim() !== "")) { arg.unshift(msg.payload); } if ((node.addpay === true) && (msg.payload.trim() !== "")) { arg.unshift(msg.payload); }

View File

@ -23,7 +23,7 @@ module.exports = function(RED) {
this.op2 = n.op2 || "0"; this.op2 = n.op2 || "0";
this.op1type = n.op1type || "val"; this.op1type = n.op1type || "val";
this.op2type = n.op2type || "val"; this.op2type = n.op2type || "val";
this.extend = n.extend || false; this.extend = n.extend || "false";
this.units = n.units || "ms"; this.units = n.units || "ms";
this.duration = n.duration || 250; this.duration = n.duration || 250;
if (this.duration <= 0) { this.duration = 0; } if (this.duration <= 0) { this.duration = 0; }

View File

@ -56,12 +56,12 @@ module.exports = {
logSpy = sinon.spy(log,"log"); logSpy = sinon.spy(log,"log");
logSpy.FATAL = log.FATAL; logSpy.FATAL = log.FATAL;
logSpy.ERROR = log.ERROR; logSpy.ERROR = log.ERROR;
logSpy.WARN = log.WARN; logSpy.WARN = log.WARN;
logSpy.INFO = log.INFO; logSpy.INFO = log.INFO;
logSpy.DEBUG = log.DEBUG; logSpy.DEBUG = log.DEBUG;
logSpy.TRACE = log.TRACE; logSpy.TRACE = log.TRACE;
logSpy.METRIC = log.METRIC; logSpy.METRIC = log.METRIC;
if (typeof testCredentials === 'function') { if (typeof testCredentials === 'function') {
cb = testCredentials; cb = testCredentials;
testCredentials = {}; testCredentials = {};
@ -94,7 +94,7 @@ module.exports = {
testNode[i](RED); testNode[i](RED);
} }
} else { } else {
testNode(RED); testNode(RED);
} }
flows.load().then(function() { flows.load().then(function() {
should.deepEqual(testFlows, flows.getFlows()); should.deepEqual(testFlows, flows.getFlows());
@ -138,14 +138,17 @@ module.exports = {
//TODO consider saving TCP handshake/server reinit on start/stop/start sequences //TODO consider saving TCP handshake/server reinit on start/stop/start sequences
stopServer: function(done) { stopServer: function(done) {
if(server) { if(server) {
server.close(done); try {
server.close(done);
} catch(e) {
done();
}
} }
}, },
url: function() { return url; }, url: function() { return url; },
nock: nock, nock: nock,
log: function() { return logSpy;} log: function() { return logSpy;}
}; };