Skip to content

Perform simple boilerplate associated with handling configurations.

License

Notifications You must be signed in to change notification settings

sal-ortiz/configuration-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Configuration Wrapper

A simple wrapper to handle most of the boilerplate associated with handling configuration files.

Installation:

npm install --save configuration-wrapper

Initialization:

const Configuration = require('configuration-wrapper');

Configuration.fromFile('input.xml');  // load an XML file.
Configuration.fromFile('input.yml');  // load a YAML file.
Configuration.fromFile('input.json'); // load a JSON file.

or

const File = require('fs');

let rawBuf = readFileSync('input.yml'); // YAML, JSON, or XML file

Configuration.fromString(rawBuf.toString())

Other Tricks

output

let cfg = Configuration.fromFile('input.json');

cfg.toJSON();   // output as a JSON string.
cfg.toYAML();   // output as a YAML string.
cfg.toXML();    // output as a XML string.

or from a command line:

bin/to-json.js input.xml
bin/to-yaml.js input.json
bin/to-xml.js input.yml