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