Tidy up API passed to node modules

This commit is contained in:
Nick O'Leary
2015-11-24 22:38:42 +00:00
parent 043b8a3105
commit f03aff7006
18 changed files with 195 additions and 99 deletions

View File

@@ -32,6 +32,7 @@ function Flow(global,flow) {
this.start = function(diff) {
var node;
var newNode;
var id;
catchNodeMap = {};
statusNodeMap = {};
@@ -39,7 +40,10 @@ function Flow(global,flow) {
if (flow.configs.hasOwnProperty(id)) {
node = flow.configs[id];
if (!activeNodes[id]) {
activeNodes[id] = createNode(node.type,node);
newNode = createNode(node.type,node);
if (newNode) {
activeNodes[id] = newNode;
}
}
}
}
@@ -57,7 +61,10 @@ function Flow(global,flow) {
node = flow.nodes[id];
if (!node.subflow) {
if (!activeNodes[id]) {
activeNodes[id] = createNode(node.type,node);
newNode = createNode(node.type,node);
if (newNode) {
activeNodes[id] = newNode;
}
}
} else {
if (!subflowInstanceNodes[id]) {
@@ -65,7 +72,9 @@ function Flow(global,flow) {
var nodes = createSubflow(flow.subflows[node.subflow]||global.subflows[node.subflow],node,flow.subflows,global.subflows,activeNodes);
subflowInstanceNodes[id] = nodes.map(function(n) { return n.id});
for (var i=0;i<nodes.length;i++) {
activeNodes[nodes[i].id] = nodes[i];
if (nodes[i]) {
activeNodes[nodes[i].id] = nodes[i];
}
}
} catch(err) {
console.log(err.stack)
@@ -438,8 +447,10 @@ function createSubflow(sf,sfn,subflows,globalSubflows,activeNodes) {
var m = /^subflow:(.+)$/.exec(type);
if (!m) {
var newNode = createNode(type,node);
activeNodes[node.id] = newNode;
nodes.push(newNode);
if (newNode) {
activeNodes[node.id] = newNode;
nodes.push(newNode);
}
} else {
var subflowId = m[1];
nodes = nodes.concat(createSubflow(subflows[subflowId]||globalSubflows[subflowId],node,subflows,globalSubflows,activeNodes));

View File

@@ -222,7 +222,7 @@ function start(type,diff) {
log.info(log._("nodes.flows.missing-type-install-2"));
log.info(" "+settings.userDir);
}
return;
return when.resolve();
}
if (diff) {
log.info(log._("nodes.flows.starting-modified-"+type));
@@ -270,6 +270,7 @@ function start(type,diff) {
} else {
log.info(log._("nodes.flows.started-flows"));
}
return when.resolve();
}
function stop(type,diff) {
@@ -387,6 +388,7 @@ module.exports = {
*/
stopFlows: stop,
started: function() { return started },
handleError: handleError,
handleStatus: handleStatus,