mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
parent
962a29110c
commit
ee6c6266cc
@ -68,6 +68,20 @@ class Flow {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an error-level message from this flow
|
||||
* @param {[type]} msg [description]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
error(msg) {
|
||||
Log.log({
|
||||
id: this.id||"global",
|
||||
level: Log.ERROR,
|
||||
type:this.TYPE,
|
||||
msg:msg
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a info-level message from this flow
|
||||
* @param {[type]} msg [description]
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user