Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When using gulp. Is there any way to suppress the 'Started' and 'Finished' log entries for certain tasks

Tags:

node.js

gulp

When using gulp. Is there any way to suppress the 'Started' and 'Finished' log entries for certain tasks? I want to use the dependency tree, but I have a few tasks in the tree that I don't want logging for because they are intermediary steps that have their own logging facilities.

like image 213
JimTheDev Avatar asked Mar 20 '14 16:03

JimTheDev


People also ask

Which of the following Gulp script is used to delete a specific folder when we run gulp clean demo?

var del = require('del'); The del function takes in an array of node globs which tells it what folders to delete. Setting it up with a Gulp task is almost like the first “hello” example we had. Now Gulp will delete the `dist` folder for you whenever gulp clean:dist is run.

What does gulp command do?

Gulp is a task runner that uses Node. js as a platform. Gulp purely uses the JavaScript code and helps to run front-end tasks and large-scale web applications. It builds system automated tasks like CSS and HTML minification, concatenating library files, and compiling the SASS files.

What is Gulp watch command?

Advertisements. The Watch method is used to monitor your source files. When any changes to the source file is made, the watch will run an appropriate task. You can use the 'default' task to watch for changes to HTML, CSS, and JavaScript files.


2 Answers

You can use the --silent flag with the gulp CLI to disable all gulp logging.

https://github.com/gulpjs/gulp/blob/master/docs/CLI.md

like image 62
slamborne Avatar answered Oct 23 '22 20:10

slamborne


[UPDATE]

As of July 2014, a --silent option has been added to gulp (https://github.com/gulpjs/gulp/commit/3a62b2b3dbefdf91c06e523245ea3c8f8342fa2c#diff-6515adedce347f8386e21d15eb775605).

This is demonstrated in @slamborne answer below, and you should favor using it instead of the below solution if it matches your use case.

[/UPDATE]

Here is a way of doing it (inside your gulpfile):

var cl = console.log;
console.log = function () {
    var args = Array.prototype.slice.call(arguments);
    if (args.length) {
        if (/^\[.*gulp.*\]$/.test(args[0])){
            return;
        }
    }
    return cl.apply(console, args);
};

... and that will ignore EVERY message sent using gutil.log.

The trick here obviously is to inspect messages sent to console.log for a first argument that looks like "[gulp]" (see gulp.util.log source code) and eventually ignore it entirely.

Now, this really is dirty - you really shouldn't do that without parental supervision, and you have been warned :-)

like image 7
Mangled Deutz Avatar answered Oct 23 '22 19:10

Mangled Deutz