How to switch output from task to task

294 Views Asked by At

Is it possible to switch Gulp's output between tasks?

For example, I'd like to run my build task continuously and see its output by default, and I want to be able to replace build's output with eslint's output, but only if such occurs. So, I can see build's output again, if all offences are corrected.

Seemed pretty straightforward before I started to tinker. Am I missing something?

1

There are 1 best solutions below

0
On

Not a proper solution. But here's an idea.

var originalStdoutWrite = process.stdout.write;
process.stdout.write = function(){ return; }
gulp.src(['**/*.js','!node_modules/**'])
    .pipe(eslint())
    .pipe(eslint.results(results => {
        // Called once for all ESLint results.
        if(results.errorCount>0){
            originalStdoutWrite.call(process.stdout,`Total Results: ${results.length}`);
        }else{
            process.stdout.write = originalStdoutWrite;
        }
    }));