mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Skip non-existent node directories
This commit is contained in:
parent
4dce130acb
commit
bc8683f40a
45
red/nodes.js
45
red/nodes.js
@ -20,6 +20,7 @@ var path = require("path");
|
|||||||
var clone = require("clone");
|
var clone = require("clone");
|
||||||
var events = require("./events");
|
var events = require("./events");
|
||||||
var storage = null;
|
var storage = null;
|
||||||
|
var settings = null;
|
||||||
|
|
||||||
function getCallerFilename(type) {
|
function getCallerFilename(type) {
|
||||||
//if (type == "summary") {
|
//if (type == "summary") {
|
||||||
@ -233,7 +234,9 @@ function createNode(node,def) {
|
|||||||
Node.call(node,def);
|
Node.call(node,def);
|
||||||
}
|
}
|
||||||
|
|
||||||
function load(settings) {
|
function load(_settings) {
|
||||||
|
settings = _settings;
|
||||||
|
|
||||||
function scanForNodes(dir) {
|
function scanForNodes(dir) {
|
||||||
var pm = path.join(dir,"node_modules");
|
var pm = path.join(dir,"node_modules");
|
||||||
if (fs.existsSync(pm)) {
|
if (fs.existsSync(pm)) {
|
||||||
@ -269,27 +272,29 @@ function load(settings) {
|
|||||||
|
|
||||||
function loadNodes(dir) {
|
function loadNodes(dir) {
|
||||||
var errors = [];
|
var errors = [];
|
||||||
fs.readdirSync(dir).sort().filter(function(fn){
|
if (fs.existsSync(dir)) {
|
||||||
var stats = fs.statSync(path.join(dir,fn));
|
fs.readdirSync(dir).sort().filter(function(fn){
|
||||||
if (stats.isFile()) {
|
var stats = fs.statSync(path.join(dir,fn));
|
||||||
if (/\.js$/.test(fn)) {
|
if (stats.isFile()) {
|
||||||
try {
|
if (/\.js$/.test(fn)) {
|
||||||
require(path.join(dir,fn));
|
try {
|
||||||
} catch(err) {
|
require(path.join(dir,fn));
|
||||||
errors.push({fn:fn, err:err});
|
} catch(err) {
|
||||||
//util.log("["+fn+"] "+err);
|
errors.push({fn:fn, err:err});
|
||||||
//console.log(err.stack);
|
//util.log("["+fn+"] "+err);
|
||||||
|
//console.log(err.stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (stats.isDirectory()) {
|
||||||
|
// Ignore /.dirs/, /lib/ /node_modules/
|
||||||
|
if (!/^(\..*|lib|icons|node_modules)$/.test(fn)) {
|
||||||
|
errors = errors.concat(loadNodes(path.join(dir,fn)));
|
||||||
|
} else if (fn === "icons") {
|
||||||
|
events.emit("node-icon-dir",path.join(dir,fn));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (stats.isDirectory()) {
|
});
|
||||||
// Ignore /.dirs/, /lib/ /node_modules/
|
}
|
||||||
if (!/^(\..*|lib|icons|node_modules)$/.test(fn)) {
|
|
||||||
errors = errors.concat(loadNodes(path.join(dir,fn)));
|
|
||||||
} else if (fn === "icons") {
|
|
||||||
events.emit("node-icon-dir",path.join(dir,fn));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
var errors = loadNodes(__dirname+"/../nodes");
|
var errors = loadNodes(__dirname+"/../nodes");
|
||||||
|
Loading…
Reference in New Issue
Block a user