alexyoe
alexyoe

Reputation: 75

Why is gulp throwing "Did you forget to signal async completion?"

I have the following gulp file that was working fine for months until this morning:

//gulpfile.js
const gulp = require('gulp')
const { series } = require('gulp')
const rename = require('gulp-rename')
const uglify = require('gulp-uglify')
const sass = require('gulp-sass')(require('sass'))

function minJs() {
    return gulp
        .src('./dev/js/script.js')
        .pipe(uglify())
        .pipe(
            rename({
                extname: '.min.js'
            })
        )
        .pipe(gulp.dest('./build/js/'))
}
exports.minJs = minJs

function minCss() {
    return gulp
        .src('./dev/css/style.sass')
        .pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
        .pipe(
            rename({
                extname: '.min.css'
            })
        )
        .pipe(gulp.dest('./build/css/'))
}
exports.minCss = minCss

exports.test = () => {
    series(minCss, minJs)
}

Every time I run "Gulp test" I get the following error:

[11:17:59] Starting 'test'...
[11:17:59] The following tasks did not complete: test
[11:17:59] Did you forget to signal async completion?

I've tried adding a callback to the two tasks and tried changing them to async functions but neither resolved the issue. I'm not sure why I'm getting this error since I am returning a stream.

Any help is appreciated!

Upvotes: 0

Views: 51

Answers (1)

edemaine
edemaine

Reputation: 3120

gulp.series is actually a higher-order rule, i.e., it makes a rule out of rules, so shouldn't be wrapped in a closure:

exports.test = series(minCss, minJs);

Upvotes: 1

Related Questions