diff --git a/packages/node_modules/@node-red/runtime/lib/flows/Flow.js b/packages/node_modules/@node-red/runtime/lib/flows/Flow.js index 9cf9b1cbb..23f41e0ed 100644 --- a/packages/node_modules/@node-red/runtime/lib/flows/Flow.js +++ b/packages/node_modules/@node-red/runtime/lib/flows/Flow.js @@ -416,68 +416,6 @@ class Flow { return this.activeNodes; } - /** - * Get a flow setting value deined in this flow. - * @param {String} key - * @return {Object} result containinig val property or null - */ - getFlowSetting(name) { - const flow = this.flow; - if (flow.credentials === undefined) { - flow.credentials = credentials.get(flow.id) || {}; - } - if (flow.env) { - if (!name.startsWith("$parent.")) { - if (!flow._env) { - const envs = flow.env; - const entries = envs.map((env) => { - if (env.type === "cred") { - const cred = flow.credentials; - if (cred.hasOwnProperty(env.name)) { - env.value = cred[env.name]; - } - } - return [env.name, env] - }); - flow._env = Object.fromEntries(entries); - } - const env = flow._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 = redUtil.evaluateNodeProperty(value, type, null, null, null); - return { - val: val - }; - } - catch (e) { - this.error(e); - return null; - } - } - } - } - } - return null; - } - /*! * Get value of environment variable defined in group node. * @param {String} group - group node @@ -562,9 +500,51 @@ class Flow { * @return {[type]} [description] */ getSetting(key) { - const result = this.getFlowSetting(key); - if (result) { - return result.val; + const flow = this.flow; + if (flow.credentials === undefined) { + flow.credentials = credentials.get(flow.id) || {}; + } + if (flow.env) { + if (!key.startsWith("$parent.")) { + if (!flow._env) { + const envs = flow.env; + const entries = envs.map((env) => { + if (env.type === "cred") { + const cred = flow.credentials; + if (cred.hasOwnProperty(env.name)) { + env.value = cred[env.name]; + } + } + return [env.name, env] + }); + flow._env = Object.fromEntries(entries); + } + const env = flow._env[key]; + if (env) { + let value = env.value; + const type = env.type; + if ((type !== "env") || (value !== key)) { + if (type === "env") { + value = value.replace(new RegExp("\\${"+key+"}","g"),"${$parent."+key+"}"); + } + try { + if (type === "bool") { + const val = ((value === "true") || + (value === true)); + return val; + } + if (type === "cred") { + return value; + } + var val = redUtil.evaluateNodeProperty(value, type, null, null, null); + return val; + } + catch (e) { + this.error(e); + } + } + } + } } return this.parent.getSetting(key); }