https://github.com/maxdome/yaml-config-lib
Loads the given and existing .yml files
https://github.com/maxdome/yaml-config-lib
Last synced: about 1 year ago
JSON representation
Loads the given and existing .yml files
- Host: GitHub
- URL: https://github.com/maxdome/yaml-config-lib
- Owner: maxdome
- Created: 2016-01-27T14:45:50.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-06-16T12:51:01.000Z (almost 10 years ago)
- Last Synced: 2025-04-18T22:13:26.672Z (about 1 year ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[]
(https://travis-ci.org/maxdome/yaml-config-lib)
[](https://david-dm.org/maxdome/yaml-config-lib)
[](https://david-dm.org/maxdome/yaml-config-lib#info=devDependencies)
# Install
Run ```npm i mxd-yaml-config-lib --save```
# Example
```javascript
const directory = __dirname + '/../config';
const config = require('mxd-yaml-config-lib')([
directory + '/all.yml', // Global default config
directory + '/' + (process.env.NODE_ENV || 'development') + '.yml', // Environment default config
directory + '/local.yml' // Config for the current instance
]);
```
# Directory structure
* config
* .gitignore - With content ```/local```
* all.yml - Global default config
* development.yml - Development default config
* production.yml - Production default config
* local.yml - Config for the current instance
# Attention
If you overwrite a leap of a tree, the complete tree will be overwritten.
e.g.:
* Some defaults for database options in the ```all.yml```:
```yaml
database:
connection: ''
options:
key: 'value'
```
* Overwrite only the connection part in the ```local.yml```:
```yaml
database:
connection: 'url'
```
* The merged config will only have the connection part, not anymore the options part with the default options:
```yaml
database:
connection: 'url'
```