Pro Grunt

LOGGING

grunt.log

grunt.log.write 
grunt.log.writeln 
grunt.log.ok 
grunt.log.error 
grunt.log.subhead 

grunt.log.subhead('grunt.log.write()');
grunt.log.write('write ');
grunt.log.write('will keep writing without a newline');


grunt.log.subhead('grunt.log.writeln()');
grunt.log.writeln('Write some text, followed by a newline');

grunt.log.subhead('grunt.log.ok()');
grunt.log.ok();
grunt.log.ok('Indicate that something is going well');

grunt.log.subhead('grunt.log.error');
grunt.log.error();
grunt.log.error('Indicate that something is NOT going well');

GRUNT.LOG.verbose

grunt.log.verbose.(ok|error|writeln) 
grunt.log.debug.(ok|error|writeln)
grunt.log.verbose.or.writeln 
grunt.fatal.warn


grunt mytask --verbose --debug
grunt.log.subhead('Debugging In Grunt');

grunt.log.writeln('Doing something complex...');
grunt.log.writeln(); // Print a blank newline

grunt.log.verbose.subhead('Reading and updating files');
grunt.log.verbose.ok('Reading file A');
grunt.log.verbose.ok('Updated file A');
grunt.log.verbose.error('Could not read file B');

grunt.log.verbose.debug('Skipping an important step because we couldn\'t read a file');
grunt.log.verbose.or.debug('Skipping an important step');

grunt.fail.warn('Failed to do something complex');

grunt.log.subhead('This happened after a failure');
grunt.log.ok('You tricky guy, you must have used --force');

BONUS 1


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);
});

Bonus 2


How to not generate

a 9.5MB CSS File


Bonus 3










https://github.com/dylang/grunt-prompt

 







@JoshSchumacher

bit.ly/gruntLog

Pro Grunt - Logging

By Josh Schumacher

Pro Grunt - Logging

A quick basic overview of logging in your grunt tasks

  • 15,211