Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to log colored messages with grunt.log

Tags:

I want to log a warning, yellow message, with Grunt, when running a specific task.

Currently I use grunt.log.subhead to output bold font, but it does no take to much attention.

grunt.log.subhead 'You may want to use --sourceMaps option' 
like image 899
paulodiovani Avatar asked Oct 16 '14 18:10

paulodiovani


2 Answers

You can try this:

grunt.log.writeln('You may want to use --sourceMaps option'['yellow'].bold); 

The grunt API documentation for log does not mention how to do this. I found it in a set of slides here: http://slides.com/joshschumacher/grunt-logging#/

like image 131
Jon John Avatar answered Oct 20 '22 03:10

Jon John


From the slides mentioned by @jon, valid colors are:

var colors = ['white', 'black', 'grey', 'blue', 'cyan', 'green', 'magenta', 'red', 'yellow', 'rainbow'];  colors.forEach(function (color) {   grunt.log.writeln('testing'[color]);   grunt.log.writeln('testing bold'[color].bold); }); 
like image 44
Jim Geurts Avatar answered Oct 20 '22 02:10

Jim Geurts