3.0.2 • Published 8 years ago
refig v3.0.2
Refig
Manage configuration files with
Promise
objects.
Refig is a library for reading and parsing configuration files. It handles directories, uses a parser of your choice, caches configurations, and is based on top of Promise
objects (for a nice asynchronous flow).
Installation
$ npm install --save refig
Usage
import Refig from 'refig';
const refig = new Refig();
API
Refig
Kind: global class
new Refig(opts)
Param | Type | Description |
---|---|---|
opts | Object | Options |
refig.load
Read and parse a configuration file.
Kind: instance property of Refig
Param | Type | Description |
---|---|---|
path | Array | String | A string (or array of strings) of a path. |
refig.merge
Fetch multiple configurations and merge them.
Kind: instance property of Refig
Param | Type | Description |
---|---|---|
path | Array | String | A string (or array of strings) of a path. |
refig.pick
Pick a single attribute out of a file.
Kind: instance property of Refig
Param | Type | Description |
---|---|---|
path | Array | String | A string (or array of strings) of a path. |
name | String | Name of the attribute to pick. |
refig.purge
Purge a file from the cache.
Kind: instance property of Refig
Param | Type | Description |
---|---|---|
path | Array | String | A string (or array of strings) of a path. |
refig.set
Set an option
Kind: instance property of Refig
Examples
Since Refig is designed around Promise
objects, you can do some pretty interesting things.
refig.merge('~/foo/bar.json', '/usr/share/foo/bar.json')
.then(opts => Object.assign(opts, refig.pick('package.json', 'foo')))
.then(opts => {
// two configurations + package.json settings, all merged.
});
Credits
@jamen |
License
MIT © Jamen Marzonie