update according to PR comments

This commit is contained in:
Hiroyasu Nishiyama
2021-08-30 08:00:58 +09:00
parent 6aecc3915c
commit d78e5932f9
8 changed files with 176 additions and 128 deletions

View File

@@ -515,66 +515,6 @@ function setObjectProperty(msg,prop,value,createMissing) {
return true;
}
/*!
* 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 {
if (type === "bool") {
const val = ((value === "true") ||
(value === true));
return {
val: val
};
}
if (type === "cred") {
return {
val: value
};
}
var val = evaluateNodeProperty(value, type, node, null, null);
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;
}
/*!
* Get value of environment variable.
* @param {Node} node - accessing node
@@ -586,7 +526,7 @@ function getSetting(node, name, flow_) {
if (flow) {
if (node && node.g) {
const group = flow.getGroupNode(node.g);
const result = getGroupSetting(node, group, flow, name);
const result = flow.getGroupEnvSetting(node, group, name);
if (result) {
return result.val;
}