diff --git a/Gruntfile.js b/Gruntfile.js index 95d372f0fa6..039f3b63274 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -15,17 +15,20 @@ module.exports = function (grunt) { // load task definitions grunt.loadTasks('tasks'); - // Utility function to load plugin configurations into an object - function loadConfig(path) { - var object = {}; + // Utility function to load plugin settings into config + function loadConfig(config,path) { require('glob').sync('*', {cwd: path}).forEach(function(option) { - object[option.replace(/\.js$/,'')] = require(path + option)(config); + var key = option.replace(/\.js$/,''); + // If key already exists, extend it. It is your responsibility to avoid naming collisions + config[key] = config[key] || {}; + grunt.util._.extend(config[key], require(path + option)(config)); }); - return object; + // technically not required + return config; } // Merge that object with what with whatever we have here - grunt.util._.extend(config, loadConfig('./tasks/options/')); + loadConfig(config,'./tasks/options/'); // pass the config to grunt grunt.initConfig(config);