mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Allow core nodes dir to be provided to runtime via settings
This commit is contained in:
parent
4a91c27e4b
commit
05b58e9263
@ -44,11 +44,15 @@ module.exports = {
|
||||
userSettings = httpServer;
|
||||
httpServer = null;
|
||||
}
|
||||
|
||||
|
||||
if (!userSettings.SKIP_BUILD_CHECK) {
|
||||
checkBuild();
|
||||
}
|
||||
|
||||
if (!userSettings.coreNodesDir) {
|
||||
userSettings.coreNodesDir = path.resolve(path.join(__dirname,"..","nodes"));
|
||||
}
|
||||
|
||||
if (userSettings.httpAdminRoot !== false || userSettings.httpNodeRoot !== false) {
|
||||
runtime.init(userSettings,api);
|
||||
api.init(httpServer,runtime);
|
||||
|
@ -23,21 +23,13 @@ var log;
|
||||
var i18n;
|
||||
|
||||
var settings;
|
||||
var defaultNodesDir = path.resolve(path.join(__dirname,"..","..","..","..","nodes"));
|
||||
var disableNodePathScan = false;
|
||||
|
||||
function init(runtime,_defaultNodesDir,_disableNodePathScan) {
|
||||
function init(runtime) {
|
||||
settings = runtime.settings;
|
||||
events = runtime.events;
|
||||
log = runtime.log;
|
||||
i18n = runtime.i18n;
|
||||
|
||||
if (_disableNodePathScan) {
|
||||
disableNodePathScan = _disableNodePathScan;
|
||||
}
|
||||
if (_defaultNodesDir) {
|
||||
defaultNodesDir = path.resolve(_defaultNodesDir);
|
||||
}
|
||||
}
|
||||
|
||||
function isExcluded(name) {
|
||||
@ -139,7 +131,7 @@ function scanDirForNodesModules(dir,moduleName) {
|
||||
* @return a list of node modules: {dir,package}
|
||||
*/
|
||||
function scanTreeForNodesModules(moduleName) {
|
||||
var dir = defaultNodesDir;
|
||||
var dir = settings.coreNodesDir;
|
||||
var results = [];
|
||||
var userDir;
|
||||
|
||||
@ -193,19 +185,13 @@ function getModuleNodeFiles(module) {
|
||||
return results;
|
||||
}
|
||||
|
||||
function getNodeFiles(_defaultNodesDir,disableNodePathScan) {
|
||||
|
||||
if (_defaultNodesDir) {
|
||||
defaultNodesDir = _defaultNodesDir;
|
||||
}
|
||||
|
||||
function getNodeFiles(disableNodePathScan) {
|
||||
var dir;
|
||||
// Find all of the nodes to load
|
||||
//console.log(defaultNodesDir);
|
||||
var nodeFiles = getLocalNodeFiles(path.resolve(defaultNodesDir));
|
||||
var nodeFiles = getLocalNodeFiles(path.resolve(settings.coreNodesDir));
|
||||
//console.log(nodeFiles);
|
||||
|
||||
var defaultLocalesPath = path.resolve(path.join(defaultNodesDir,"core","locales"));
|
||||
var defaultLocalesPath = path.resolve(path.join(settings.coreNodesDir,"core","locales"));
|
||||
i18n.registerMessageCatalog("node-red",defaultLocalesPath,"messages.json");
|
||||
|
||||
if (settings.userDir) {
|
||||
@ -250,6 +236,8 @@ function getNodeFiles(_defaultNodesDir,disableNodePathScan) {
|
||||
});
|
||||
nodeFiles = nodeFiles.concat(nodeModuleFiles);
|
||||
});
|
||||
} else {
|
||||
console.log("node path scan disabled");
|
||||
}
|
||||
return nodeList;
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
}
|
||||
describe("#getNodeFiles",function() {
|
||||
it("Finds all the node files in the resources tree",function(done) {
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{}});
|
||||
var nodeList = localfilesystem.getNodeFiles(resourcesDir,true);
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{coreNodesDir:resourcesDir}});
|
||||
var nodeList = localfilesystem.getNodeFiles(true);
|
||||
nodeList.should.have.a.property("node-red");
|
||||
var nm = nodeList['node-red'];
|
||||
nm.should.have.a.property('name','node-red');
|
||||
@ -56,8 +56,8 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
done();
|
||||
});
|
||||
it("Excludes node files from settings",function(done) {
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{nodesExcludes:['TestNode1.js']}});
|
||||
var nodeList = localfilesystem.getNodeFiles(resourcesDir,true);
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{nodesExcludes:['TestNode1.js'],coreNodesDir:resourcesDir}});
|
||||
var nodeList = localfilesystem.getNodeFiles(true);
|
||||
nodeList.should.have.a.property("node-red");
|
||||
var nm = nodeList['node-red'];
|
||||
nm.should.have.a.property('name','node-red');
|
||||
@ -66,8 +66,8 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
done();
|
||||
});
|
||||
it("Finds nodes in userDir/nodes",function(done) {
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{userDir:userDir}});
|
||||
var nodeList = localfilesystem.getNodeFiles(__dirname,true);
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{userDir:userDir,coreNodesDir:__dirname}});
|
||||
var nodeList = localfilesystem.getNodeFiles(true);
|
||||
nodeList.should.have.a.property("node-red");
|
||||
var nm = nodeList['node-red'];
|
||||
nm.should.have.a.property('name','node-red');
|
||||
@ -77,8 +77,8 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
});
|
||||
|
||||
it("Finds nodes in settings.nodesDir (string)",function(done) {
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{nodesDir:userDir}});
|
||||
var nodeList = localfilesystem.getNodeFiles(__dirname,true);
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{nodesDir:userDir,coreNodesDir:__dirname}});
|
||||
var nodeList = localfilesystem.getNodeFiles(true);
|
||||
nodeList.should.have.a.property("node-red");
|
||||
var nm = nodeList['node-red'];
|
||||
nm.should.have.a.property('name','node-red');
|
||||
@ -87,8 +87,8 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
done();
|
||||
});
|
||||
it("Finds nodes in settings.nodesDir (array)",function(done) {
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{nodesDir:[userDir]}});
|
||||
var nodeList = localfilesystem.getNodeFiles(__dirname,true);
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{nodesDir:[userDir],coreNodesDir:__dirname}});
|
||||
var nodeList = localfilesystem.getNodeFiles(true);
|
||||
nodeList.should.have.a.property("node-red");
|
||||
var nm = nodeList['node-red'];
|
||||
nm.should.have.a.property('name','node-red');
|
||||
@ -106,8 +106,8 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
}
|
||||
return _join.apply(null,arguments);
|
||||
}));
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{}});
|
||||
var nodeList = localfilesystem.getNodeFiles(moduleDir,false);
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{coreNodesDir:moduleDir}});
|
||||
var nodeList = localfilesystem.getNodeFiles();
|
||||
nodeList.should.have.a.property("node-red");
|
||||
var nm = nodeList['node-red'];
|
||||
nm.should.have.a.property('name','node-red');
|
||||
@ -141,7 +141,7 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
}
|
||||
return _join.apply(null,arguments);
|
||||
}));
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{}},moduleDir,true);
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{coreNodesDir:moduleDir}});
|
||||
var nodeModule = localfilesystem.getModuleFiles('TestNodeModule');
|
||||
nodeModule.should.have.a.property('TestNodeModule');
|
||||
nodeModule['TestNodeModule'].should.have.a.property('name','TestNodeModule');
|
||||
@ -165,7 +165,7 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
}
|
||||
return _join.apply(null,arguments);
|
||||
}));
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{}},moduleDir,true);
|
||||
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{coreNodesDir:moduleDir}});
|
||||
/*jshint immed: false */
|
||||
(function(){
|
||||
localfilesystem.getModuleFiles('WontExistModule');
|
||||
|
Loading…
Reference in New Issue
Block a user