Gulp - Getting the return value from one task to another
I am new to GulpJS and was tasked with doing something fairly simple: append a git hash to index.html.
Getting the current git hash was easy enough:
What I struggled with with the Gulp-way of replace ‘append git hash here!’ with the actual git hash.
Running a function that would return the git hash would not work because the tasks are asyncronous.
My initial solution (which probably isn’t the Gulp-way of doing it) was just to wrap the tasks ina q promise.
I was able to get some help from Steve Lacy, the creator of several Gulp plugins. His solution just involves creating a global variable, and making the html task dependent on the hash (aka, html won’t run until hash is finished).