Search code examples
error-handlingruntime-errorwatchgulp-4

Gulp 4 keep watching even on error


How can I make this

// ...
gulp.watch(source.app, gulp.series(
    lint(source.app),
    transpile(source.app),
    ATDD,
));

To keep watching even if error occurred from linter or transpiler?

My task function looks like this:

// ...
function lintWorker(source) {
    return gulp.src(source)
                .pipe(tslint({
                    configuration: "tslint.json",
                    options : {
                        formatter: "prose"
                    }
                }))
                .pipe(tslint.report(stylish, {
                    emitError: false,
                    sort: true,
                    bell: true
                }));
};
export function lint(source) {
    let fn = () => {
        return lintWorker(source);
    };
    fn.displayName = ["linting", ...source].join(" ");
    return fn;
};

Solution

  • I found the simple way how to do it.

    gulp.watch(source.app, (done) => {
        gulp.series(
            lint(source.app),
            transpile(source.app),
            ATDD,
        )((err) => {
            if (err) {
                console.error("error", err);
            }
            done();
        });
    });