configuration: finish 2.2.0, update readme

This commit is contained in:
Tobe O 2020-05-04 12:05:14 -04:00
parent 8738154537
commit 76fe71a474
4 changed files with 19 additions and 4 deletions

View file

@ -38,9 +38,17 @@ You can also load configuration from the environment:
system_path: $PATH
```
If a `.env` file is present in your configuration directory, then it will be loaded before
If a `.env` file is present in your configuration directory (i.e. `config/.env`), then it will be loaded before
applying YAML configuration.
You can also include values from one file into another:
```yaml
_include:
- "./include-prod.yaml"
- "./include-misc.yaml"
_include: "just-one-file.yaml"
```
**Server-side**
Call `configuration()`. The loaded configuration will be available in your application's
`configuration` map.
@ -71,4 +79,4 @@ foo:
bar: baz
quux: goodbye
yellow: submarine
```
```

View file

@ -21,7 +21,7 @@ Future<void> _loadYamlFile(Map map, File yamlFile, Map<String, String> env,
var out = {};
var configMap = config as Map;
var configMap = Map.of(config as Map);
// Check for _include
if (configMap.containsKey('_include')) {

View file

@ -33,6 +33,7 @@ Future<void> main() async {
'angel': {'framework': 'cool'},
'must_be_null': null,
'artist': 'Timberlake',
'included': true,
'merge': {'map': true, 'hello': 'world'},
'set_via': 'default',
'hello': 'world',
@ -40,6 +41,10 @@ Future<void> main() async {
});
});
test('obeys included paths', () async {
expect(app.configuration['included'], true);
});
test('can load based on ANGEL_ENV', () async {
expect(app.configuration['hello'], equals('world'));
expect(app.configuration['foo']['version'], equals('bar'));

View file

@ -1,3 +1,5 @@
_include:
- "./include.yaml"
hello: world
foo:
version: bar
version: bar