There is a parent folder (gulp module) which has some child folders (gulp modules too). I want to run the default gulp task of each child through the gulpfile of the parent.
My approach was to iterate through the folders by using gulp-folders and run a gulp through gulp-shell by setting the current work directory to the corresponding child.
var tOptions = {};
[...]
gulp.task('setup-modules', folders('./', function(folder){
tOptions.cwd = folder;
gulp.start('setup-module');
return gulp.src('', {read: false});
}));
gulp.task('setup-module', shell.task([
'gulp'
], tOptions));
It seems that just one instance of the task setup-module gets started. What do I need to change to get several instances (for each child folder) of the task running?
Instead of using
gulp-shellyou can usegulp-chugand pass a glob togulp.src()to access your child gulpfiles eliminating the need to iterate over each subdirectory. You can even specify which tasks you would like to run if you want to run any task(s) other thandefault.Additionally,
gulp-chugwill do everything so there's no need to depend on more than just that one package accomplish what you're looking to do.One of the examples from the
gulp-chugdocs goes over almost the exact scenario you're discussing.gulpfile.js (parent)