The setting loader is a module that allows to load settings in the form of a JSON. This JSON file can include various parameters. We call them settings.
The settings should be overridable in the following levels :
- default settings in a setting folder, in a JSON file. We might use
HJSON
- override settings loaded depending on the ENV : production / staging / development
Β This overriding should take the following form :
load(settings/settings.${ENV}.json)
ifload(settings/settings.${ENV}.json)
fail, triesload(settings/${ENV}.json)
else triesload(settings/settings.json)
- override based on the default path where a setting can be found (inspired from rc):
-
$HOME/.${appname}/rc
-
$HOME/.${appname}/settings.json
-
$HOME/.setting/${appname}
-
$HOME/.setting/${appname}/settings.json
-
Folder defined here: https://electron.atom.io/docs/all/#appgetpathname Β
- override base on a file input : providing a
--settings
option then this setting file should be loaded. If the setting file can not be found or parsing is wrong, a warning should be thrown and the other setting should be loaded
Looks like https://github.com/indexzero/nconf is doing exactly what we need. Except from the
HJSON
part. Need to test.