Closed Willyham closed 9 years ago
:-1: This can be completely done outside this module.
// config/common.json
{
"url": "htps://{username}.internal.service.com"
}
// main.js
var Config = require('zero-config');
var template = require('string-template');
var conf = Config(__dirname);
var urlPattern = conf.get('url');
var url = template(urlPattern, 'willyham');
A configuration loader should not have template resolution build into it.
Alright
@Raynos @collenjones
This adds the ability to add a list of replacements to the options. If replacements are defined, we'll load the JSON and potentially do some string replacements on each key before adding it to the config tree. This could be useful for many scenarios, but the impetus behind this was to support the use case of changing URLs on development boxes. For example, we might want to rewrite:
"https://$username.internal.service.com" to "https://willyham.internal.service.com"
In which case, we would pass this with our config options:
It also supports regex for more complex replacements.
I still need to add readme info and update versions, but I'd like your feedback first.