mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
update according to PR comments
This commit is contained in:
@@ -43,54 +43,6 @@ function evaluateInputValue(value, type, node) {
|
||||
return redUtil.evaluateNodeProperty(value, type, node, null, null);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get value of environment variable defined in group node.
|
||||
* @param {String} group - group node
|
||||
* @param {String} name - name of variable
|
||||
* @return {Object} object containing the value in val property or null if not defined
|
||||
*/
|
||||
function getGroupSetting(node, group, flow, name) {
|
||||
if (group) {
|
||||
if (!name.startsWith("$parent.")) {
|
||||
if (group.env) {
|
||||
if (!group._env) {
|
||||
const envs = group.env;
|
||||
const entries = envs.map((env) => [env.name, env]);
|
||||
group._env = Object.fromEntries(entries);
|
||||
}
|
||||
const env = group._env[name];
|
||||
if (env) {
|
||||
let value = env.value;
|
||||
const type = env.type;
|
||||
if ((type !== "env") || (value !== name)) {
|
||||
if (type === "env") {
|
||||
value = value.replace(new RegExp("\\${"+name+"}","g"),"${$parent."+name+"}");
|
||||
}
|
||||
try {
|
||||
const val = evaluateInputValue(value, type, node);
|
||||
return {
|
||||
val: val
|
||||
};
|
||||
}
|
||||
catch (e) {
|
||||
this.error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
name = name.substring(8);
|
||||
}
|
||||
if (group.g && flow) {
|
||||
const parent = flow.getGroupNode(group.g);
|
||||
return getGroupSetting(node, parent, flow, name);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This class represents a subflow - which is handled as a special type of Flow
|
||||
*/
|
||||
@@ -421,7 +373,7 @@ class Subflow extends Flow {
|
||||
const node = this.subflowInstance;
|
||||
if (node.g) {
|
||||
const group = this.getGroupNode(node.g);
|
||||
const result = getGroupSetting(node, group, this, name);
|
||||
const result = this.getGroupEnvSetting(node, group, name);
|
||||
if (result) {
|
||||
return result.val;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user