mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
initial support for npm module installation
This commit is contained in:
@@ -26,6 +26,7 @@ var flows = require("../flows");
|
||||
var flowUtil = require("../flows/util")
|
||||
var context = require("./context");
|
||||
var Node = require("./Node");
|
||||
var npmModule = require("./npmModule");
|
||||
var log;
|
||||
|
||||
const events = require("@node-red/util").events;
|
||||
@@ -49,6 +50,7 @@ function registerType(nodeSet,type,constructor,opts) {
|
||||
type = nodeSet;
|
||||
nodeSet = "";
|
||||
}
|
||||
var dynModule = null;
|
||||
if (opts) {
|
||||
if (opts.credentials) {
|
||||
credentials.register(type,opts.credentials);
|
||||
@@ -60,7 +62,11 @@ function registerType(nodeSet,type,constructor,opts) {
|
||||
log.warn("["+type+"] "+err.message);
|
||||
}
|
||||
}
|
||||
if (opts.dynamicModuleList) {
|
||||
dynModule = opts.dynamicModuleList;
|
||||
}
|
||||
}
|
||||
npmModule.register(type, dynModule);
|
||||
if(!(constructor.prototype instanceof Node)) {
|
||||
if(Object.getPrototypeOf(constructor.prototype) === Object.prototype) {
|
||||
util.inherits(constructor,Node);
|
||||
@@ -110,6 +116,7 @@ function createNode(node,def) {
|
||||
} else if (credentials.getDefinition(node.type)) {
|
||||
node.credentials = {};
|
||||
}
|
||||
return npmModule.checkInstall(def);
|
||||
}
|
||||
|
||||
function registerSubflow(nodeSet, subflow) {
|
||||
@@ -138,6 +145,7 @@ function init(runtime) {
|
||||
flows.init(runtime);
|
||||
registry.init(runtime);
|
||||
context.init(runtime.settings);
|
||||
npmModule.init(runtime);
|
||||
}
|
||||
|
||||
function disableNode(id) {
|
||||
@@ -261,5 +269,9 @@ module.exports = {
|
||||
// Contexts
|
||||
loadContextsPlugin: context.load,
|
||||
closeContextsPlugin: context.close,
|
||||
listContextStores: context.listStores
|
||||
listContextStores: context.listStores,
|
||||
|
||||
// NPM modules
|
||||
listNPMModules: npmModule.list,
|
||||
loadNPMModule: npmModule.load
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user