This commit is contained in:
Glenn Block 2013-06-14 01:24:42 -06:00
Родитель 28ca19f19a
Коммит 1256a47219
1 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -1,8 +1,7 @@
envconf
===========
This module makes it easy to use express-style configuration for whatever application
you want. Easily let your users define separate configuration environments in code
This module makes it easy to use express-style configuration for any application. It easily allows to let your users define separate configuration environments in code
and switch between sets of configuration via a single environment variable.
@ -14,22 +13,23 @@ var envconf = require('envconf');
var c = envconf.createConfig();
c.configure('dev', function (c) {
c.configure('development', function (c) {
c.set('settingOne', 'devValue');
});
c.configure('prod', function (c) {
c.configure('production', function (c) {
c.set('settingTwo', 'prodValue');
});
c('dev').get('settingOne').should.equal('devValue');
process.env.NODE_ENV = 'prod';
process.env.NODE_ENV = 'production';
c.default.get('settingTwo').should.equal('prodValue');
```
It picks up the default environment from the NODE_ENV environment variable, but you can
change that if you want:
The previous code shows picking up the default environment from the NODE_ENV environment variable.
You can however configure to use your own environment variables as shown below.
```javascript
@ -49,7 +49,7 @@ process.env.MY_LIBRARY_VAR = 'prod';
c.default.get('settingTwo').should.equal('prodValue');
```
Do you want to add helper methods to your configuration? It's easy
Do you want to add helper methods for your specific configuration? It's easy
with a config customizer:
```javascript