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

Add nodesDir property to all nodes files to exist elsewhere

This commit is contained in:
Nicholas O'Leary 2013-11-13 17:02:29 +00:00
parent 851c2ab089
commit 3a52397744
3 changed files with 15 additions and 7 deletions

View File

@ -16,6 +16,7 @@
var util = require("util");
var EventEmitter = require("events").EventEmitter;
var fs = require("fs");
var path = require("path");
var events = require("./events");
var storage = null;
@ -215,14 +216,14 @@ module.exports.registerType = node_type_registry.register;
module.exports.getNodeConfigs = node_type_registry.getNodeConfigs;
module.exports.addLogHandler = registry.addLogHandler;
module.exports.load = function() {
module.exports.load = function(settings) {
function loadNodes(dir) {
fs.readdirSync(dir).sort().filter(function(fn){
var stats = fs.statSync(dir+"/"+fn);
var stats = fs.statSync(path.join(dir,fn));
if (stats.isFile()) {
if (/\.js$/.test(fn)) {
try {
require(dir+"/"+fn);
require(path.join(dir,fn));
} catch(err) {
util.log("["+fn+"] "+err);
//console.log(err.stack);
@ -231,14 +232,17 @@ module.exports.load = function() {
} else if (stats.isDirectory()) {
// Ignore /.dirs/ and /lib/
if (!/^(\..*|lib|icons)$/.test(fn)) {
loadNodes(dir+"/"+fn);
loadNodes(path.join(dir,fn));
} else if (fn === "icons") {
events.emit("node-icon-dir",dir+"/"+fn);
events.emit("node-icon-dir",path.join(dir,fn));
}
}
});
}
loadNodes(__dirname+"/../nodes");
if (settings.nodesDir) {
loadNodes(settings.nodesDir);
}
//events.emit("nodes-loaded");
}

View File

@ -66,7 +66,7 @@ function start() {
console.log("\nWelcome to Node-RED\n===================\n");
util.log("[red] Loading palette nodes");
util.log("------------------------------------------");
redNodes.load();
redNodes.load(settings);
util.log("");
util.log('You may ignore any errors above here if they are for');
util.log('nodes you are not using. The nodes indicated will not');

View File

@ -40,7 +40,11 @@ module.exports = {
// By default, all user data is stored in the Node-RED install directory. To
// use a different location, the following property can be used
//userDir: '/home/nol/.node-red/',
// Node-RED scans the `nodes` directory in the install directory to find nodes.
// The following property can be used to specify an additional directory to scan.
//nodesDir: '/home/nol/.node-red/nodes',
// You can protect the user interface with a userid and password by using the following property
// the password must be an md5 hash eg.. 5f4dcc3b5aa765d61d8327deb882cf99 ('password')
//httpAuth: {user:"user",pass:"5f4dcc3b5aa765d61d8327deb882cf99"},