Skip to content

A NodeJS module based off of Python's ConfigParser. It implements a basic configuration file parser.

Notifications You must be signed in to change notification settings

eswets/configparser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Config Parser CircleCI

A NodeJS module based off of Python's ConfigParser. It implements a basic configuration file parser. The structure is very similar to the Windows INI file.

Installation

npm install configparser

Documentation

See Full Documentation Here

Example

Writing

There are two methods available for writing the contents of the config file to disk: write and writeAsync.

const ConfigParser = require('configparser');

const config = new ConfigParser();

// Adding sections and adding keys
config.addSection('User');
config.set('User', 'token', 'some value');
config.set('User', 'exp', 'some value');

// With String Interpolation, %(key_name)s
config.addSection('MetaData');
config.set('MetaData', 'path', '/home/%(dir_name)s/');
config.set('MetaData', 'dir_name', 'me');

config.write('my-cfg-file.cfg');
File
[User]
token=some value
exp=some value

[MetaData]
path=/home/%(dir_name)s/
dir_name=me
Reading

There are two methods available for reading the contents of the config file from disk: read and readAsync.

config.read('my-cfg-file.cfg');
config.sections(); // ['User', 'MetaData']
config.get('User', 'token'); // 'some value'
config.get('MetaData', 'path'); // '/home/me/'

Questions and Issues

Use the Github Issue Tracker to report a bug, request a feature, or if you need any help.

About

A NodeJS module based off of Python's ConfigParser. It implements a basic configuration file parser.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%