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

Fix node enable/disable over restart - load configs after settings init

This commit is contained in:
Nick O'Leary 2016-07-15 00:11:28 +01:00
parent a457c06500
commit d57425a15e
3 changed files with 20 additions and 8 deletions

View File

@ -29,7 +29,12 @@ function init(runtime) {
settings = runtime.settings;
installer.init(runtime.settings);
loader.init(runtime);
registry.init(runtime.settings,loader);
registry.init(settings,loader);
}
function load() {
registry.load();
return loader.load();
}
function addModule(module) {
@ -52,7 +57,7 @@ function enableNodeSet(typeOrId) {
module.exports = {
init:init,
load:loader.load,
load:load,
clear: registry.clear,
registerType: registry.registerNodeConstructor,

View File

@ -35,11 +35,6 @@ var moduleNodes = {};
function init(_settings,_loader) {
settings = _settings;
loader = _loader;
if (settings.available()) {
moduleConfigs = loadNodeConfigs();
} else {
moduleConfigs = {};
}
moduleNodes = {};
nodeTypeToId = {};
nodeConstructors = {};
@ -48,6 +43,14 @@ function init(_settings,_loader) {
Node = require("../Node");
}
function load() {
if (settings.available()) {
moduleConfigs = loadNodeConfigs();
} else {
moduleConfigs = {};
}
}
function filterNodeInfo(n) {
var r = {
id: n.id||n.module+"/"+n.name,
@ -535,6 +538,7 @@ function cleanModuleList() {
var registry = module.exports = {
init: init,
load: load,
clear: clear,
registerNodeConstructor: registerNodeConstructor,

View File

@ -75,9 +75,11 @@ describe("red/nodes/registry/registry",function() {
describe('#init', function() {
describe('#init/load', function() {
it('loads initial config', function(done) {
typeRegistry.init(settingsWithStorageAndInitialConfig);
typeRegistry.getNodeList().should.have.lengthOf(0);
typeRegistry.load();
typeRegistry.getNodeList().should.have.lengthOf(1);
done();
});
@ -113,6 +115,7 @@ describe("red/nodes/registry/registry",function() {
};
var expected = JSON.parse('{"node-red":{"name":"node-red","nodes":{"sentiment":{"name":"sentiment","types":["sentiment"],"enabled":true,"module":"node-red"},"inject":{"name":"inject","types":["inject"],"enabled":true,"module":"node-red"}}},"testModule":{"name":"testModule","nodes":{"a-module.js":{"name":"a-module.js","types":["example"],"enabled":true,"module":"testModule"}}}}');
typeRegistry.init(legacySettings);
typeRegistry.load();
legacySettings.set.calledOnce.should.be.true;
legacySettings.set.args[0][1].should.eql(expected);
done();