Automatic desktop notifications for Grunt errors and warnings using Growl for OS X or Windows, Mountain Lion Notification Center, Snarl, and Notify-Send.
This plugin recommends Grunt 0.4.1
or newer.
npm install grunt-notify --save-dev
Once that's done, add this line to your project's Gruntfile.js
:
// Automatic notifications when tasks fail.
grunt.loadNpmTasks('grunt-notify');
That's all you need for automatic notifications.
If you want change the automatic messaging configure a task called notify_hooks
.
grunt.initConfig({
// This is optional!
notify_hooks: {
options: {
enabled: true,
max_jshint_notifications: 5, // maximum number of notifications from jshint output
title: "Project Name" // defaults to the name in package.json, or uses project's directory name, you can change to the name of your project
}
}
});
// Load the task
grunt.loadNpmTasks('grunt-notify');
// This is required if you use any options.
grunt.task.run('notify_hooks');
Sometimes you want to show messages like "Uglify complete" or "Project Deployed" - that's easy to do too.
grunt.initConfig({
notify: {
task_name: {
options: {
// Task-specific options go here.
}
},
watch: {
options: {
title: 'Task Complete', // optional
message: 'SASS and Uglify finished running', //required
}
},
server: {
options: {
message: 'Server is ready!'
}
}
}
});
grunt.loadNpmTasks('grunt-notify');
// simplified example
grunt.registerTask('server', [
'uglify',
'sass',
'server',
'notify:server'
]);
title
optional Notification titlemessage
required Notification message
Run grunt
to lint and run the tests.
Run grunt --debug
to show grunt-notify
debug messages. Create an issue and I'll look into it asap.
Apple does not provide an API to the OS X Notification Center that Node can access. Only code written in Objective C and signed in XCode can use it. This is not very friendly for Node users so we are using the tiny signed MIT-licensed native application Terminal Notifier from Eloy Durán. I've changed the default icon which is owned by Apple to the Grunt logo.
This project was created for and is used by the free game I co-created for Node Knockout called Doodle or Die. Please give it a try, we think you will enjoy it!
See CHANGELOG.md for changes.