Fix up loading of freshly installed modules in Function node

This commit is contained in:
Nick O'Leary
2021-02-12 22:40:30 +00:00
parent 9c09ee3b71
commit a94c19a6cf
2 changed files with 6 additions and 7 deletions

View File

@@ -89,15 +89,13 @@ module.exports = function(RED) {
}
function FunctionNode(n) {
var libs = n.libs || [];
n.modules = libs.map(x => x.spec).filter(x => (x && (x !== "")));
RED.nodes.createNode(this,n);
var node = this;
node.name = n.name;
node.func = n.func;
node.ini = n.initialize ? n.initialize.trim() : "";
node.fin = n.finalize ? n.finalize.trim() : "";
node.libs = libs || [];
node.libs = n.libs || [];
if (RED.settings.functionExternalModules === false && node.libs.length > 0) {
throw new Error("Function node not allowed to load external modules");
@@ -298,9 +296,9 @@ module.exports = function(RED) {
if (vname && (vname !== "")) {
sandbox[vname] = null;
try {
var spec = module.spec;
var spec = module.module;
if (spec && (spec !== "")) {
var lib = RED.require(module.spec);
var lib = RED.require(module.module);
sandbox[vname] = lib;
}
}