Skip to content

Instantly share code, notes, and snippets.

@deepsweet
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepsweet/38d87035c32decc93cac to your computer and use it in GitHub Desktop.
Save deepsweet/38d87035c32decc93cac to your computer and use it in GitHub Desktop.
ugly hack to suppress too verbose grunt-newer
module.exports = function(grunt) {
// https://github.com/tschaub/grunt-newer/issues/52
// https://github.com/gruntjs/grunt/issues/895
var origLogHeader = grunt.log.header;
grunt.log.header = function(msg) {
if (!/newer(-postrun)?:/.test(msg)) {
origLogHeader.apply(this, arguments);
}
};
// ...
};
@Rycochet
Copy link

My slightly improved version -

// Remove grunt-newer spam
var origLogHeader = grunt.log.header,
        origLogWriteln = grunt.log.writeln;

grunt.log.header = function(msg) {
    if (/^Running "newer(-postrun)?:/.test(msg)) {
        grunt.verbose.header.apply(grunt.verbose, arguments);
    } else {
        origLogHeader.apply(this, arguments);
    }
    return this;
};
grunt.log.writeln = function(msg) {
    if (/^No newer files to process./.test(msg)) {
        grunt.verbose.writeln.apply(grunt.verbose, arguments);
    } else {
        origLogWriteln.apply(this, arguments);
    }
    return this;
};

Occasionally there is chaining which needs return this, plus I might want to sometimes see the spam, so moved it into --verbose ;-)

@jrodl3r
Copy link

jrodl3r commented Mar 10, 2015

This will remove it from the 'time-grunt' output as well

if (prevTaskName && prevTaskName !== name && prevTaskName.indexOf('newer') < 0)

if (prevTaskName && prevTaskName.indexOf('newer') < 0) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment