CLI apps normally use configurations for different situations like:
Saving the state of an app and restoring it.
Having global and user level configurations for their own benefits.
Maintaining interval threshold value for cron like activities.
Storing strings for Internationalization and localization.
And many more similar use cases.
ConfigStore is one such node module that helps you to easily load and persist config without having to think about where and how!
This is wonderful module is a gift from Yeoman which has about 18432 downloads yesterday alone!
Installing is it just like any other module:
$ npm install configstore
The API set is very simple had has:
set(key, val)-> Set an item.
get(key)-> Get an item.
del(key)-> To delete an item.
all-> Get all the items in the current config store and replace them all with a new object.
size-> Count of the items.
path-> File path to the config store.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
Under the covers:
For the above example:
1 2 3 4 5 6