Add Global Options

This commit is contained in:
Valentin Boettcher 2017-08-25 17:47:36 +02:00
parent d30f750ed8
commit 66f79a7555

View file

@ -20,7 +20,7 @@ module.exports = plugin;
* @return {Function}
*/
function plugin(opts){
function plugin(opts, globalOpts){
opts = normalize(opts);
var keys = Object.keys(opts);
var match = matcher(opts);
@ -57,6 +57,16 @@ function plugin(opts){
metadata[key] = metadata[key] || [];
});
/**
* Merge global options with collection options
*/
keys.forEach(function(key){
for(var gKey in globalOpts){
opts[key][gKey] = opts[key][gKey] || globalOpts[gKey];
}
});
/**
* Sort the collections.
*/