Skip to content

maxdome/yaml-config-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[Travis CI] (https://travis-ci.org/maxdome/yaml-config-lib) Dependency Status devDependency Status

Install

Run npm i mxd-yaml-config-lib --save

Example

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:
database:
  connection: ''
  options:
    key: 'value'
  • Overwrite only the connection part in the local.yml:
database:
  connection: 'url'
  • The merged config will only have the connection part, not anymore the options part with the default options:
database:
  connection: 'url'

About

Loads the given and existing .yml files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published