mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
@@ -263,17 +263,37 @@ class Subflow extends Flow {
|
||||
* @return {Object} val value of env var
|
||||
*/
|
||||
getSetting(name) {
|
||||
var env = this.env;
|
||||
if (env && env.hasOwnProperty(name)) {
|
||||
var val = env[name];
|
||||
try {
|
||||
var ret = redUtil.evaluateNodeProperty(val.value, val.type, this.node, null, null);
|
||||
return ret;
|
||||
}
|
||||
catch (e) {
|
||||
this.error(e);
|
||||
return undefined;
|
||||
this.trace("getSetting:"+name);
|
||||
if (!/^\$parent\./.test(name)) {
|
||||
var env = this.env;
|
||||
if (env && env.hasOwnProperty(name)) {
|
||||
var val = env[name];
|
||||
// If this is an env type property we need to be careful not
|
||||
// to get into lookup loops.
|
||||
// 1. if the value to lookup is the same as this one, go straight to parent
|
||||
// 2. otherwise, check if it is a compound env var ("foo $(bar)")
|
||||
// and if so, substitute any instances of `name` with $parent.name
|
||||
// See https://github.com/node-red/node-red/issues/2099
|
||||
if (val.type !== 'env' || val.value !== name) {
|
||||
let value = val.value;
|
||||
if (val.type === 'env') {
|
||||
value = value.replace(new RegExp("\\${"+name+"}","g"),"${$parent."+name+"}");
|
||||
}
|
||||
try {
|
||||
var ret = redUtil.evaluateNodeProperty(value, val.type, this.node, null, null);
|
||||
return ret;
|
||||
}
|
||||
catch (e) {
|
||||
this.error(e);
|
||||
return undefined;
|
||||
}
|
||||
} else {
|
||||
// This _is_ an env property pointing at itself - go to parent
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// name starts $parent. ... so delegate to parent automatically
|
||||
name = name.substring(8);
|
||||
}
|
||||
var parent = this.parent;
|
||||
if (parent) {
|
||||
|
||||
Reference in New Issue
Block a user