fixed comments from @knolleary

This commit is contained in:
Hiroyasu Nishiyama
2019-01-28 22:14:08 +09:00
parent 2b43e3ee23
commit f88a4b1791
8 changed files with 76 additions and 97 deletions

View File

@@ -419,9 +419,12 @@ function setObjectProperty(msg,prop,value,createMissing) {
* @param {String} name - name of variable
* @return {String} value of env var
*/
function getenv(node, name) {
if (node && node.getenv) {
return node.getenv(name);
function getSetting(node, name) {
if (node && node._flow) {
var flow = node._flow;
if (flow) {
return flow.getSetting(name);
}
}
return process.env[name];
}
@@ -442,16 +445,16 @@ function evaluateEnvProperty(value, node) {
if (/^\${[^}]+}$/.test(value)) {
// ${ENV_VAR}
var name = value.substring(2,value.length-1);
var val = getenv(node, name);
var val = getSetting(node, name);
return val ? val : "";
} else if (!/\${\S+}/.test(value)) {
// ENV_VAR
var val = getenv(node, value);
var val = getSetting(node, value);
return val ? val : "";
} else {
// FOO${ENV_VAR}BAR
return value.replace(/\${([^}]+)}/g, function(match, name) {
var val = getenv(node, name);
var val = getSetting(node, name);
return (val ? val : "");
});
}
@@ -558,7 +561,7 @@ function prepareJSONataExpression(value,node) {
return node.context().global.get(val);
});
expr.assign('env', function(name) {
var val = getenv(node, name);
var val = getSetting(node, name);
return (val ? val : "");
})
expr.registerFunction('clone', cloneMessage, '<(oa)-:o>');