You can build some function that handle an array of plugin/type to filter those which are needed :
[{
"plugin": "plugin_a_name",
"types": ["js"]
}, {
"plugin": "plugin_b_name"
}]
In the above sub-config, it will only copy JS file for plugin_a and all the types (JS/CSS) for plugin_b.
You can then iterate over all the filtered plugin/types and grab them from your config path.json file if existing :
var gulp = require('gulp'),
config = require('./path.json');
function copyTask(target) {
//iterate over config files for the specified type
for (src in target) {
console.log("copy from " + src + " to " + target[src]);
gulp.src(src).pipe(gulp.dest(target[src]));
}
}
function copyFilter(pluginFilter) {
//loop on filter
for (var obj in pluginFilter) {
var pluginVal = pluginFilter[obj];
//check config has plugin
if (config[pluginVal.plugin]) {
if (pluginVal.types) {
//loop on type type filter
for (var type in pluginVal.types) {
var typeVal = pluginVal.types[type];
// check config has type
if (config[pluginVal.plugin][typeVal]) {
copyTask(config[pluginVal.plugin][typeVal]);
} else {
console.log("type " + typeVal + " not found for plugin " + pluginVal.plugin);
}
}
} else {
//iterate over all the types here
for (type in config[pluginVal.plugin]) {
copyTask(config[pluginVal.plugin][type]);
}
}
} else {
console.log("plugin " + pluginVal.plugin + " not found");
}
}
}
gulp.task('copyFromJson', function() {
copyFilter([{
"plugin": "plugin_a_name",
"types": ["js"]
}, {
"plugin": "plugin_b_name"
}]);
});
gulp.task('default', ['copyFromJson']);