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:
62
packages/node_modules/@node-red/util/lib/util.js
vendored
62
packages/node_modules/@node-red/util/lib/util.js
vendored
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user