14

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?

askhat
  • 59
  • 2
  • 19

1 Answers1

1

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;
        }
    }));
Sibin
  • 356
  • 3
  • 6