From bb0e48f2719cbeb2c0f0d12a5c2da432a5e6e293 Mon Sep 17 00:00:00 2001 From: Anna Thomas Date: Mon, 8 Dec 2014 09:43:59 +0000 Subject: [PATCH] Store version in settings --- red/nodes/registry.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/red/nodes/registry.js b/red/nodes/registry.js index bd28a00f1..4d0bdfaa5 100644 --- a/red/nodes/registry.js +++ b/red/nodes/registry.js @@ -68,9 +68,18 @@ var registry = (function() { for (var module in moduleConfigs) { if (moduleConfigs.hasOwnProperty(module)) { if (!moduleList[module]) { - moduleList[module] = {}; - moduleList[module].name = module; - moduleList[module].nodes = {}; + var version; + if (module === "node-red") { + version = settings.version; + } else { + version = moduleConfigs[module].version; + } + + moduleList[module] = { + name: module, + version: version, + nodes: {} + }; } var nodes = moduleConfigs[module].nodes; for(var node in nodes) { @@ -95,7 +104,7 @@ var registry = (function() { function loadNodeConfigs() { var configs = settings.get("nodes"); - + if (!configs) { return {}; } else if (configs['node-red']) { @@ -108,34 +117,34 @@ var registry = (function() { var nodeConfig = configs[id]; var moduleName; var nodeSetName; - + if (nodeConfig.module) { moduleName = nodeConfig.module; nodeSetName = nodeConfig.name.split(":")[1]; } else { moduleName = "node-red"; - nodeSetName = nodeConfig.name.replace(/^\d+-/,"").replace(/\.js$/,"") + nodeSetName = nodeConfig.name.replace(/^\d+-/,"").replace(/\.js$/,""); } - + if (!newConfigs[moduleName]) { newConfigs[moduleName] = { name: moduleName, nodes:{} - } + }; } newConfigs[moduleName].nodes[nodeSetName] = { name: nodeSetName, types: nodeConfig.types, enabled: nodeConfig.enabled, module: moduleName - } + }; } } settings.set("nodes",newConfigs); return newConfigs; } } - + return { init: function() { if (settings.available()) { @@ -625,6 +634,7 @@ function loadNodeConfig(file,module,name,version) { node.err = err.toString(); } } + registry.addNodeSet(id,node,version); return node; }