Gulp task does not run (but turns callback)

3

I have a task in gulp, defined more or less like this:

gulp.task('tarefa', ['a', 'b', 'c'], function () {
   console.log("tarefa executada com sucesso");
});

From what I understood from documentation , this code should do the following:

  • Set the task to ;
  • Run the jobs , "b" and "
  • After completing the "a", "b" and "c" tasks, execute the defined logic for the task. / li>

What really happens:

  • The task name task is set;
  • The "a", "b" and "c" tasks run in parallel;
  • The program for, indicating success, but the logic I set for the task task is not executed.

However, I noticed that if in the other tasks I receive a parameter, and treat this parameter as a function ... For example:

gulp.task('a', function (callback) {
    callback();
});

The callback above is the function that I defined as the task body task .

I would like to run my task only after the others have run, and as they will run in parallel, I can not use my function as a callback for the other tasks.

What should I do?

    
asked by anonymous 03.06.2015 / 14:50

1 answer

1

We can indicate in a task what its dependency is, ie, what task should be performed before.

See this example that the copy job waits for the clean task to finish executing:

// adicionando clean como dependência da tarefa copy

//na tarefa copy passo ['clean']

gulp.task('copy', ['clean'], function() {
    gulp.src('src/**/*')
        .pipe(gulp.dest('dist'));
});

//na tarefa clean passo return
gulp.task('clean', function(){
    return gulp.src('dist')
        .pipe(clean());   
});

See that tasks are executed one at a time, because in this context it does not make sense to run them in parallel

    
20.03.2017 / 05:48