0

I am creating some gulp tasks with dynamic task names. These tasks need to be run in order, not parallel. I am putting the task names in an array, but I am getting an error from run-sequence. I assume this error is a problem with how I am listing the tasks from the array in my run-sequence code.

This is what I'm doing:

var taskNames = ['task1', 'task2', 'task3']

Then for run sequence I'm trying to do this:

gulp.task('run-dynamic-tasks', function(){
  runSequence(
    taskNames.join(", \n"),
    function(){
      browserSync.reload();
    }
  );
});

This does not work and gives this error:

Error: Task task1,

task2,

task3 is not configured as a task on gulp. If this is a submodule (error continues)

Please note, if there is only one task in the array, such as:

var taskNames = ['task1']

then this code works.

I believe this is probably a javascript mistake, as opposed to run-sequence or node.

thank you for any and all help, Scott

1 Answer 1

4

Turns out this is indeed a basic javascript problem. I should have been using function.apply

Final gulp.task is this:

gulp.task('run-dynamic-tasks', function(){
  runSequence.apply(null, taskNamesArray);
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.