mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Enabling and disabling non-existent nodes throws an error
This commit is contained in:
		| @@ -319,13 +319,15 @@ var registry = (function() { | ||||
|             if (!settings.available()) { | ||||
|                 throw new Error("Settings unavailable"); | ||||
|             } | ||||
|  | ||||
|             var id = typeOrId; | ||||
|             if (nodeTypeToId[typeOrId]) { | ||||
|                 id = nodeTypeToId[typeOrId]; | ||||
|             } | ||||
|             var config = moduleConfigs[getModule(id)].nodes[getNode(id)]; | ||||
|  | ||||
|             if (config) { | ||||
|             var config; | ||||
|             try { | ||||
|                 config = moduleConfigs[getModule(id)].nodes[getNode(id)]; | ||||
|                 delete config.err; | ||||
|                 config.enabled = true; | ||||
|                 if (!config.loaded) { | ||||
| @@ -334,7 +336,7 @@ var registry = (function() { | ||||
|                 } | ||||
|                 nodeConfigCache = null; | ||||
|                 saveNodeList(); | ||||
|             } else { | ||||
|             } catch (err) { | ||||
|                 throw new Error("Unrecognised id: "+typeOrId); | ||||
|             } | ||||
|             return filterNodeInfo(config); | ||||
| @@ -348,14 +350,14 @@ var registry = (function() { | ||||
|             if (nodeTypeToId[typeOrId]) { | ||||
|                 id = nodeTypeToId[typeOrId]; | ||||
|             } | ||||
|             var config = moduleConfigs[getModule(id)].nodes[getNode(id)]; | ||||
|  | ||||
|             if (config) { | ||||
|             var config; | ||||
|             try { | ||||
|                 config = moduleConfigs[getModule(id)].nodes[getNode(id)]; | ||||
|                 // TODO: persist setting | ||||
|                 config.enabled = false; | ||||
|                 nodeConfigCache = null; | ||||
|                 saveNodeList(); | ||||
|             } else { | ||||
|             } catch (err) { | ||||
|                 throw new Error("Unrecognised id: "+id); | ||||
|             } | ||||
|             return filterNodeInfo(config); | ||||
|   | ||||
| @@ -991,14 +991,14 @@ describe('NodeRegistry', function() { | ||||
|     }); | ||||
|  | ||||
|     it('fails to enable/disable non-existent nodes', function(done) { | ||||
|         typeRegistry.init(settings); | ||||
|         typeRegistry.init(settingsWithStorage); | ||||
|         typeRegistry.load("wontexist",true).then(function() { | ||||
|             var list = typeRegistry.getNodeList(); | ||||
|             list.should.be.an.Array.and.be.empty; | ||||
|  | ||||
|             /*jshint immed: false */ | ||||
|             (function() { | ||||
|                     typeRegistry.disableNode("123"); | ||||
|                 typeRegistry.disableNode("123"); | ||||
|             }).should.throw(); | ||||
|  | ||||
|             /*jshint immed: false */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user