4

I have been working on a project setup and deploy Gruntfile but would like to hide the command line output so that the following:

Running "init" task

Running "prompt:init" (prompt) task
[?] If you continue your project information will be overwritten.
    Continue? (Y/n)

becomes

[?] If you continue your project information will be overwritten.
    Continue? (Y/n)

when running grunt. I know it's only cosmetic but it's something I would like to do and cannot seem to find anything on Grunt's API documentation to indicate this can be done.

Léo Lam
  • 3,870
  • 4
  • 34
  • 44
onmylemon
  • 724
  • 8
  • 25

1 Answers1

4

This is currently not supported, but possible thanks to the following workaround (from shama on GitHub):

grunt.log.header = function () {};

Basically, this overrides the log header function (which is responsible for the "running x task" message) by an empty function that does nothing, and more importantly, outputs nothing.

There's another way to do it:

  • First, run npm install grunt-log-headers to install grunt-log-headers.
  • Then add require('grunt-log-headers')(grunt); to your Gruntfile.js to enable it.
  • Finally, add this to any task for which you want to hide the log header:

    options: {
        gruntLogHeader: false
    }
    

    Example:

    grunt.initConfig({
        sometask: {
            options: {
                gruntLogHeader: false,
            }
        }
    });
    

In fact, an issue has already been created for this. It's currently being worked on, and will normally be available in the version 0.5.0.

Léo Lam
  • 3,870
  • 4
  • 34
  • 44