Skip to content

Commit

Permalink
Improve json override doc
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-lau committed May 11, 2024
1 parent a62e13c commit 18cedaa
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Overrides work in the following manner:
key by key basis.
- For every other config format, an override file replaces the entire
config.
- If `smtp.json` or `smtp.yaml` exist, their contents will be loaded before all other config files. You can make use of [JSON Overrides](#json-overrides) here for a single file config.

## Examples

Expand Down Expand Up @@ -243,15 +244,28 @@ These are as you would expect, and returns an object as given in the file.

If a requested .json or .hjson file does not exist then the same file will be checked for with a .yaml extension and that will be loaded instead. This is done because YAML files are far easier for a human to write.

### <a name="json-overrides">JSON Overrides</a>
You can use JSON, HJSON or YAML files to override any other file by prefixing the outer variable name with a `!` e.g.

```js
{
"!smtpgreeting": [ 'this is line one', 'this is line two' ]
"!smtpgreeting": ['this is line one', 'this is line two'],
"!smtp.ini": {
main: {
nodes: 0,
},
headers: {
max_lines: 1000,
max_received: 100,
},
},
"!custom-plugin.yaml": {
secret: 'example',
},
}
```

If the config/smtpgreeting file did not exist, then this value would replace it.
If the config/smtpgreeting wasn't loaded before, then this value would replace it. Since `smtp.json` is always loaded first, it can be used to override existing config files.

NOTE: You must ensure that the data type (e.g. Object, Array or String) for the replaced value is correct. This cannot be done automatically.

Expand Down

0 comments on commit 18cedaa

Please sign in to comment.