6/06/2012

How to get Growl notifications from Grunt JS

I just started to use Grunt on a new project. While I really enjoyed Grunt I quickly missed the desktop notifications when something wrong happen. Here are two snippets that will display cross-platform growl notifications on warn/fatal Grunt events.


/* Inside grunt.js file (don't forget to add "growl" as a project dependency) */
grunt.utils.hooker.hook(grunt.fail, "warn", function(opt) {
require('growl')(opt.name, {
title: opt.message,
image: 'Console'
});
});
/* ... or, since fail.fatal() will stop grunt it seems a good idea to track it too */
var growl = require('growl');
['warn', 'fatal'].forEach(function(level) {
grunt.utils.hooker.hook(grunt.fail, level, function(opt) {
growl(opt.name, {
title: opt.message,
image: 'Console'
});
});
});
view raw grunt_growl.js hosted with ❤ by GitHub
« »
 
 
Made with on a hot august night from an airplane the 19th of March 2017.