Keep Track of the Latest Grunt Console Output

I’ve been making heavy use of Grunt in all of my projects lately. One thing that I always find annoying is that I can never figure out where the latest output from the Watch task begins and ends. I find myself scrolling up to see just what’s been happening. Luckily, Grunt makes creating new tasks a snap and so I made one to help make very clear where the output from the last Grunt run begins. I’ll give you the code after the jump.

This code is real simple so rather than create a plugin, I just write the code inline as a task at the end of my Gruntfile.

“` // A task to help us keep track of where Grunt output ends grunt.registerTask(‘delimiter’, ‘A task to make the latest Grunt output clearer’, function() { var delimiter = ‘\n\n#########################################\n’ +

              '#      Hello, Grunt! (' + grunt.template.today("h:MM:ssTT") + ')       #\n' +
              '#########################################\n\n';

grunt.log.writeln(delimiter); }); “`

Paste that at the end of your Gruntfile and then, in whichever task you need it, add the 'delimiter' task. I need it with my watch task so as part of the tasks that get run whenever I change a watched file I add tasks: ['delimiter', 'other tasks here...'].

I personally need a few newlines and a sort of real obvious flag so I know when to scroll up. Your needs may vary so just change the value of the delimiter variable.

Boom. Done. Simple. Enjoy.

Web design, Web development

« Ghost: The Overrated Blogging Platform Installing Comodo PositiveSSL Certificates on Nginx »

Comments