How to switch output from task to task
Asked Answered
P

1

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?

Perak answered 9/8, 2017 at 13:7 Comment(4)
could you provide the implementation of your task? Please post your gulpfileQuito
@TomM honestly I don't think it'd be much of help. Basically it has two tasks (one is system call made with spawn) and me staring on themPerak
Anyways gist.github.com/askhat/95ca048ae0a3f2942beb4ad55810c9d4Perak
What is spawn? What it does? I dont get your question, sorry.Relume
E
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;
        }
    }));
Execrable answered 3/9, 2017 at 15:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.