nconf-transforms
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -30,3 +30,4 @@ var config = require('nconf'); | ||
return config; | ||
}; | ||
{ | ||
"name": "nconf-transforms", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "web.config like transforms for nconf", | ||
"repository": "https://github.com/e-r-w/nconf-transforms", | ||
"dependencies": { | ||
@@ -6,0 +7,0 @@ "chokidar": "^1.2.0", |
# nconf-transforms | ||
Similar to .NET web.config transforms, nconf-transforms allows you to load nconf configuration files based on convention. | ||
Reads the `NODE_ENV` environment variable to select what config file to transform. | ||
Reads the `NODE_ENV` environment variable to select what config file to transform. Currently only supports JSON format. | ||
@@ -8,14 +8,10 @@ ## Usage | ||
```js | ||
require('nconf').argv().env() // don't forget to load your environment/argv variables if you want them! | ||
var transform = require('nconf-transforms'); | ||
transform({ | ||
dir: __dirname + '/config', | ||
dir: './config', | ||
reload: true // reload nconf when the config file changes | ||
}); | ||
//... | ||
var nconf = require('nconf'); | ||
nconf.get('someConfig'); | ||
``` | ||
@@ -27,5 +23,35 @@ | ||
/app | ||
app.js | ||
/config | ||
settings.json | ||
settings.production.json | ||
``` | ||
``` | ||
settings.json | ||
```json | ||
{ | ||
"someConfig": "someValue" | ||
} | ||
``` | ||
app.js | ||
```js | ||
var nconf = require('nconf'); | ||
console.log(nconf.get('someConfig')); // "someValue" | ||
``` | ||
## API | ||
`transform(options)` | ||
Loads your base configuration and transforms it using the `NODE_ENV` environment variable to find the transform file. | ||
Options: | ||
- dir: String. The directory to find the configuration files. Defaults to `__dirname`, so set it anyway. | ||
- fileName: String. The name of your configuration files (i.e `settings.json`, `settings.production.json`). Defaults to `settings` | ||
- reload: Boolean. Toggles reloading of configuration when the base config changes. | ||
Returns the `nconf` object so you can chain loading other configuration types/files. |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
2609
23
56