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:
parent
851c2ab089
commit
3a52397744
14
red/nodes.js
14
red/nodes.js
@ -16,6 +16,7 @@
|
|||||||
var util = require("util");
|
var util = require("util");
|
||||||
var EventEmitter = require("events").EventEmitter;
|
var EventEmitter = require("events").EventEmitter;
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
|
var path = require("path");
|
||||||
var events = require("./events");
|
var events = require("./events");
|
||||||
var storage = null;
|
var storage = null;
|
||||||
|
|
||||||
@ -215,14 +216,14 @@ module.exports.registerType = node_type_registry.register;
|
|||||||
module.exports.getNodeConfigs = node_type_registry.getNodeConfigs;
|
module.exports.getNodeConfigs = node_type_registry.getNodeConfigs;
|
||||||
module.exports.addLogHandler = registry.addLogHandler;
|
module.exports.addLogHandler = registry.addLogHandler;
|
||||||
|
|
||||||
module.exports.load = function() {
|
module.exports.load = function(settings) {
|
||||||
function loadNodes(dir) {
|
function loadNodes(dir) {
|
||||||
fs.readdirSync(dir).sort().filter(function(fn){
|
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 (stats.isFile()) {
|
||||||
if (/\.js$/.test(fn)) {
|
if (/\.js$/.test(fn)) {
|
||||||
try {
|
try {
|
||||||
require(dir+"/"+fn);
|
require(path.join(dir,fn));
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
util.log("["+fn+"] "+err);
|
util.log("["+fn+"] "+err);
|
||||||
//console.log(err.stack);
|
//console.log(err.stack);
|
||||||
@ -231,14 +232,17 @@ module.exports.load = function() {
|
|||||||
} else if (stats.isDirectory()) {
|
} else if (stats.isDirectory()) {
|
||||||
// Ignore /.dirs/ and /lib/
|
// Ignore /.dirs/ and /lib/
|
||||||
if (!/^(\..*|lib|icons)$/.test(fn)) {
|
if (!/^(\..*|lib|icons)$/.test(fn)) {
|
||||||
loadNodes(dir+"/"+fn);
|
loadNodes(path.join(dir,fn));
|
||||||
} else if (fn === "icons") {
|
} else if (fn === "icons") {
|
||||||
events.emit("node-icon-dir",dir+"/"+fn);
|
events.emit("node-icon-dir",path.join(dir,fn));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
loadNodes(__dirname+"/../nodes");
|
loadNodes(__dirname+"/../nodes");
|
||||||
|
if (settings.nodesDir) {
|
||||||
|
loadNodes(settings.nodesDir);
|
||||||
|
}
|
||||||
//events.emit("nodes-loaded");
|
//events.emit("nodes-loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ function start() {
|
|||||||
console.log("\nWelcome to Node-RED\n===================\n");
|
console.log("\nWelcome to Node-RED\n===================\n");
|
||||||
util.log("[red] Loading palette nodes");
|
util.log("[red] Loading palette nodes");
|
||||||
util.log("------------------------------------------");
|
util.log("------------------------------------------");
|
||||||
redNodes.load();
|
redNodes.load(settings);
|
||||||
util.log("");
|
util.log("");
|
||||||
util.log('You may ignore any errors above here if they are for');
|
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');
|
util.log('nodes you are not using. The nodes indicated will not');
|
||||||
|
@ -41,6 +41,10 @@ module.exports = {
|
|||||||
// use a different location, the following property can be used
|
// use a different location, the following property can be used
|
||||||
//userDir: '/home/nol/.node-red/',
|
//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
|
// 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')
|
// the password must be an md5 hash eg.. 5f4dcc3b5aa765d61d8327deb882cf99 ('password')
|
||||||
//httpAuth: {user:"user",pass:"5f4dcc3b5aa765d61d8327deb882cf99"},
|
//httpAuth: {user:"user",pass:"5f4dcc3b5aa765d61d8327deb882cf99"},
|
||||||
|
Loading…
Reference in New Issue
Block a user