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

Add nodesExcludes option

This commit is contained in:
Nick O'Leary 2014-04-08 13:32:46 +01:00
parent 069f42f0c5
commit 43073de10b

View File

@ -208,13 +208,20 @@ function load(_settings) {
var RED = require("./red.js");
function loadNode(nodeFilename) {
var preCount = node_type_registry.count();
function loadNode(nodeDir, nodeFn) {
if (settings.nodesExcludes) {
for (var i=0;i<settings.nodesExcludes.length;i++) {
if (settings.nodesExcludes[i] == nodeFn) {
return;
}
}
}
var nodeFilename = path.join(nodeDir,nodeFn);
var r = require(nodeFilename);
if (typeof r === "function") {
r(RED);
}
if (preCount != node_type_registry.count()) {
var templateFilename = nodeFilename.replace(/\.js$/,".html");
if (fs.existsSync(templateFilename)) {
node_type_registry.registerConfig(fs.readFileSync(templateFilename,'utf8'));
@ -222,7 +229,6 @@ function load(_settings) {
util.log("["+type+"] missing template file: "+templateFilename);
}
}
}
function scanForNodes(dir) {
var pm = path.join(dir,"node_modules");
@ -239,8 +245,8 @@ function load(_settings) {
for (var i in nrn) {
console.log(" ",i,":",nrn[i]);
try {
var nodeFilename = path.join(pm,fn,nrn[i]);
loadNode(nodeFilename);
var nodeDir = path.join(pm,fn);
loadNode(nodeDir,nrn[i]);
} catch(err) {
util.log("["+i+"] "+err);
//console.log(err.stack);
@ -266,8 +272,7 @@ function load(_settings) {
if (stats.isFile()) {
if (/\.js$/.test(fn)) {
try {
var nodeFilename = path.join(dir,fn);
loadNode(nodeFilename);
loadNode(dir,fn);
} catch(err) {
errors.push({fn:fn, err:err});
//util.log("["+fn+"] "+err);