Skip to content

Commit

Permalink
PCHR-4049: Fix tasks promises execution
Browse files Browse the repository at this point in the history
  • Loading branch information
igorpavlov committed Jul 31, 2018
1 parent 8bfd196 commit 32f8c98
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions uk.co.compucorp.civicrm.hrcore/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,29 @@ var gulp = require('gulp');
var utils = require('./gulp/utils');
var tasks = getMainTasks();

var watcherPromises = buildTaskPromises(['sass:watch', 'requirejs:watch', 'test:watch']);
var builderPromises = buildTaskPromises(['sass:watch', 'requirejs:watch', 'test:watch']);

_.each(tasks, function (fn, name) {
gulp.task(name, fn);
});

gulp.task('watch', gulp.series(
utils.spawnTaskForExtension('sass:watch', tasks['sass:watch']),
utils.spawnTaskForExtension('requirejs:watch', tasks['requirejs:watch']),
utils.spawnTaskForExtension('test:watch', tasks['test:watch'])
));
gulp.task('watch', gulp.series(watcherPromises));
gulp.task('build', gulp.series(builderPromises));

gulp.task('build', gulp.series(
utils.spawnTaskForExtension('sass', tasks['sass']),
utils.spawnTaskForExtension('requirejs', tasks['requirejs']),
utils.spawnTaskForExtension('test', tasks['test'])
));
/**
* Builds extension tasks promises
*
* @param {Array} taskNames
* @return {Array} of task promises
*/
function buildTaskPromises (taskNames) {
return taskNames.map(function (taskName) {
return function () {
return utils.spawnTaskForExtension(taskName, tasks[taskName]);
};
});
}

/**
* Gets all the task listed in the files under the gulp/task folder
Expand Down

0 comments on commit 32f8c98

Please sign in to comment.