Discussion:
[nodejs] Create dynamically (at runtime) set of gulp tasks
r***@gmail.com
2018-11-08 09:33:14 UTC
Permalink
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
--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/f119e82e-2e39-4358-8716-b9122d14b9ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...