Gulp: Run code after asynchronous tasks have completed -


i have gulp task following mission: list of folders. count words in folder. report count each folder , grand total count.

so far, have.

gulp.task('count', function() {    ['folder1','folder2',...].foreach(function(foldername) {     gulp.src(['./'+foldername+'/**/*.md']).pipe(countwords(foldername));   });  }); 

after of folders' words have been counted, want call function reportgrandtotal. have spent hours trying figure out how this. problem gulp.src().pipe() chain runs asynchronously. in many of patterns have tried, reportgrandtotal ends running before of gulp.src().pipe() chains complete.

how modify task that, once of gulp.src().pipe() chains have completed, can run reportgrandtotal , grand total?

if i'm understanding question, can specify dependency reportgrandtotal, make sure tasks use callback or return stream or promise.

gulp.task('reportgrandtotal', ['count'], function(){     // code } 

the second parameter dependency , reportgranttotal should not run before dependency done. gulp docs dependencies


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -