1
0
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:
Nick O'Leary 2014-03-21 14:05:27 +00:00
parent 4dce130acb
commit bc8683f40a

View File

@ -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,6 +272,7 @@ function load(settings) {
function loadNodes(dir) { function loadNodes(dir) {
var errors = []; var errors = [];
if (fs.existsSync(dir)) {
fs.readdirSync(dir).sort().filter(function(fn){ fs.readdirSync(dir).sort().filter(function(fn){
var stats = fs.statSync(path.join(dir,fn)); var stats = fs.statSync(path.join(dir,fn));
if (stats.isFile()) { if (stats.isFile()) {
@ -290,6 +294,7 @@ function load(settings) {
} }
} }
}); });
}
return errors; return errors;
} }
var errors = loadNodes(__dirname+"/../nodes"); var errors = loadNodes(__dirname+"/../nodes");