Grunt notify: https://github.com/dylang/grunt-notify is great. However, it seems a bit limited. As far as I can tell all my messages need to be pre-generated. So the first question is how can I generate notifications?
Next, It seems that grunt notify triggers based on error or success of some task. I guess based on std in/out/err? The problem where this breaks down is if some task doesn't use these. grunt compass doesn't use stderr if there are compile errors. So how can I run grunt notify when it has an error? This then leads to the next question. How can I grab the console output or stderr from a grunt task?
First of all, use growl. It is easy and flexible to use. To install growl:
Then you need to hook into the stderr/out stream of the process. This way you can create a notification each time a new message arrives at the stderr/out stream.
This is what I've created. I've made a CommonJs module which adds hooks to:
grunt.fail.warn(),grunt.fail.fatal()grunt.log.warn(),grunt.log.error()grunt.warn()process.stderr.write()process.stdout.write()(error lines)process.stderr.write()process.stdout.write()(error lines)It works more or less, but it may need some tweaking.
tasks/lib/notify.js
Then you need to include it in your Gruntfile.js with a
requirestatement:PS I've placed the file in
tasks/lib/notify.js, but feel free to place it somewhere else.