R
R
RaDir2017-07-17 11:32:30
JavaScript
RaDir, 2017-07-17 11:32:30

Why does gulp (v4) throw "Did you forget to signal async completion?"?

Hello!
gulpfile.js:

'use strict';

const gulp = require('gulp');
const sass = require('gulp-sass');
const clean = require('gulp-clean');

var arrBlocksNames = [
    'sass.common.blocks'
];

function cleanSassBlocks() {
    arrBlocksNames.forEach(function(blocksName) {
        return gulp.src(blocksName + '/**/*.css' )
            .pipe(clean({force: true}));
    });
}

gulp.task('default', gulp.series(cleanSassBlocks));

The console throws an error/warning:
[13:26:11] Starting 'default'...
[13:26:11] Starting 'cleanSassBlocks'...
[13:26:11] The following tasks did not complete: default, cleanSassBlocks
[13:26:11] Did you forget to signal async completion?

At the same time, everything is deleted as it should. What is the reason, tell me please?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
RaDir, 2017-07-17
@RaDir

Thanks for the answers, but I figured it out myself and solved the problem like this:

arrBlocksNames.forEach(function(blocksName) {
    gulp.task(blocksName, function() {
        return gulp.src(blocksName + '/**/*.css')
            .pipe(clean({force: true}));
    });
});

N
Nixtone, 2019-12-20
@Nixtone

You need to add done to the function argument.
And at the end of the function, write done();
That's all

A
Alexey Ukolov, 2017-07-17
@alexey-m-ukolov

return arrBlocksNames.map(...

S
spmbt, 2017-09-27
@spmbt

You need to start the continuation of the process:

function cleanSassBlocks(f) { f();
    arrBlocksNames.forEach(function(blocksName) {
        return gulp.src(blocksName + '/**/*.css' )
            .pipe(clean({force: true}));
    }); 
...

(as suggested in https://github.com/sindresorhus/del/issues/45#issu... )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question