Create dynamically (at runtime) set of gulp tasks

21 views
Skip to first unread message

rej...@gmail.com

unread,
Nov 17, 2018, 3:16:20 AM11/17/18
to nodejs

Hi,

I am trying to create dynamically (at runtime) set of gulp tasks and after that I want to execute them.

So the default task executes in series task called ‘createTasks’ which I thought would create all my tasks in array ‘tasks’ and then execute the function returned by ‘gulp.series(tasks)’. 

But it generates the error:

‘VM40 assert.js:42 Uncaught AssertionError: One or more tasks should be combined using series or parallel’

The code looks like this:


var gulp = require('gulp');

var tasks = [];
const fileArray = ['task1', 'task2'];

debugger;
gulp.task('createTasks', function(done) {
for (var key in fileArray)
{
gulp.task(fileArray[key], function(done) {
console.log("I was called");
});
tasks.push(fileArray[key]);
}});


gulp.task('default', gulp.series('createTasks', gulp.series(tasks)));



What am doing wrong?

 

Kind Regards,

Janusz

Reply all
Reply to author
Forward
0 new messages