mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add Flow.getSetting for resolving env-var properties
This lays the groundwork for subflow-specific settings
This commit is contained in:
@@ -300,7 +300,7 @@ describe('Flow', function() {
|
||||
{id:"5",x:10,y:10,z:"t1",type:"test",foo:"$(NODE_RED_TEST_VALUE_NONE)",wires:[]},
|
||||
{id:"6",x:10,y:10,z:"t1",type:"test",foo:["$(NODE_RED_TEST_VALUE)"],wires:[]}
|
||||
]);
|
||||
var flow = Flow.create({},config,config.flows["t1"]);
|
||||
var flow = Flow.create({getSetting:v=>process.env[v]},config,config.flows["t1"]);
|
||||
flow.start();
|
||||
|
||||
var activeNodes = flow.getActiveNodes();
|
||||
|
@@ -64,6 +64,18 @@ describe('flows/util', function() {
|
||||
}
|
||||
foo.should.eql({ a: 'bar1', b: 'bar2', c: { d: 'bar3' } } );
|
||||
});
|
||||
|
||||
it('gets ENV from parent flow', function() {
|
||||
var foo = {a:"$(unknown)",b:"$(foo2)",c:{d:"$(foo3)"}};
|
||||
for (var p in foo) {
|
||||
if (foo.hasOwnProperty(p)) {
|
||||
flowUtil.mapEnvVarProperties(foo,p,{
|
||||
getSetting: name => name[0]==='f'?name.toUpperCase():undefined
|
||||
});
|
||||
}
|
||||
}
|
||||
foo.should.eql({ a: '$(unknown)', b: 'FOO2', c: { d: 'FOO3' } } );
|
||||
});
|
||||
});
|
||||
|
||||
describe('#diffNodes',function() {
|
||||
|
Reference in New Issue
Block a user