Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

grunt-notify

dylang43.3kMIT0.4.5

Automatic desktop notifications for Grunt errors and warnings. Supports OS X, Windows, Linux.

gruntplugin, notification, notify, growl, mountain lion, mavericks, linux, notify-send, error, warning, automatic

readme

grunt-notify Build Status grunt-notify

Automatic desktop notifications for Grunt errors and warnings. Supports OS X, Windows, Linux.

Screenshots

OS Tool Screenshots
OS X OS X Notification Center OS X Notification Center
OS X Growl for Mac Growl for Mac
Windows 8 Windows 8 notifications Windows 8 Notifications
Windows Growl for Windows Growl for Windows
Windows Snarl Snarl
Linux Notify-Send Notify-Send

Getting Started

This plugin recommends Grunt 0.4.1 or newer.

Installing

npm install grunt-notify --save-dev

Once that's done, add this line to your project's Gruntfile.js:

grunt.loadNpmTasks('grunt-notify');

That's all you need for automatic notifications.

Notify_Hooks Options

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 will use project directory's name
      success: false, // whether successful grunt executions should be notified automatically
      duration: 3 // the duration of notification in seconds, for `notify-send only
    }
  }
});

// Load the task
grunt.loadNpmTasks('grunt-notify');

// This is required if you use any options.
grunt.task.run('notify_hooks');

Showing Specific Notifications

Sometimes you want to show messages like "Uglify complete" or "Project Deployed" - that's easy to do too.

Custom Message - Grunt
Custom Message - Grunt
Custom Message - Notification Center
Custom Message - Notification Center
Custom Message - Notify-Send
Custom Message - Notify-Send
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'
  ]);

Options

  • title optional Notification title
  • message required Notification message

Tests

Run grunt to lint and run the tests.

Notification Systems

Mac

OS X Notification System

Support Included.

If you are using OS X 10.8 Mountain Lion or newer a notification system is built in, but Apple does not provide a notification API that Node can access. Only code written in Objective C and signed in XCode can access 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.

Growl for OS X

Requires growlnotify for OS X.

Install growlnotify from the Growl Downloads Page. This will install in /usr/local/bin/growlnotify.

Windows

Snarl

Included with Snarl.

If you have downloaded and installed Snarl from Snarl's web site you'll have the commandline tool heysnarl as well.

Growl for Windows

Requires growlnotify for Windows.

Install growlnotify from the growlnotify Page.

Windows 8.1 Notifications

Nothing to install.

Create a pull request!

Linux

Notify-Send

Nothing to install.

I created an Ubuntu virtual machine and it had notify-send in the path.

I don't use Linux frequently so I don't know if this utility is available for other distros.

notify-send man page.

notify-send has an addition duration option which takes a number seconds. The default is 3 seconds.

Duration doesn't work natively on some versions of Ubuntu.

Here is a fix: http://askubuntu.com/questions/128474/how-to-customize-on-screen-notifications

Chrome

Not supported yet.

Chrome has a notification system but I'm not sure if it's possible to use from a command-line Node app. Somebody could probably create a Chrome Plugin helper for this.

Notifications aren't showing

Run grunt -v (for verbose mode) to show grunt-notify debug messages. It will tell you what notification system it thinks it can use. Create an issue and I'll look into it asap.

About the Author

Hi! Thanks for checking out this project! My name is Dylan Greene. When not overwhelmed with my two young kids I enjoy contributing to the open source community. I'm also a tech lead at Opower. @dylang @dylang

Here's some of my other Node projects:

Name Description npm Downloads
space‑hogs Discover surprisingly large directories from the command line space-hogs
npm‑check Check for outdated, incorrect, and unused dependencies. npm-check
shortid Amazingly short non-sequential url-friendly unique id generator. shortid
rss RSS feed generator. Add RSS feeds to any project. Supports enclosures and GeoRSS. rss
grunt‑prompt Interactive prompt for your Grunt config using console checkboxes, text input with filtering, password fields. grunt-prompt
xml Fast and simple xml generator. Supports attributes, CDATA, etc. Includes tests and examples. xml
changelog Command line tool (and Node module) that generates a changelog in color output, markdown, or json for modules in npmjs.org's registry as well as any public github.com repo. changelog
grunt‑attention Display attention-grabbing messages in the terminal grunt-attention
observatory Beautiful UI for showing tasks running on the command line. observatory
anthology Module information and stats for any @npmjs user anthology
grunt‑cat Echo a file to the terminal. Works with text, figlets, ascii art, and full-color ansi. grunt-cat

This list was generated using anthology.

License

Copyright (c) 2016 Dylan Greene, contributors.

Released under the MIT license.

Screenshots are CC BY-SA (Attribution-ShareAlike).


Generated using grunt-readme with grunt-templates-dylang on Sunday, February 28, 2016. _To make changes to this document look in /templates/readme/

changelog

  • 7 Nov 2014 - 0.4.0
    • Option for notification on success messages
    • Duration option for notify-send
  • 7 Aug 2014 - 0.3.1
    • Updated dependencies
  • 26 April 2014 - 0.3.0
    • Windows 8 Notifications thanks to @enzy.
  • 10 March 2014 - 0.2.20
    • Grunt icon in OS X native notifications.
    • Fix bug when it would catch errors with no messages.
    • Fix dates in changelog.
  • 2 March 2014 - 0.2.19
    • Add duration to notify-send
  • 2 March 2014 - 0.2.18
    • Avoid multiple notifications with notify-send
  • 5 January 2014 - 0.2.17
    • New documentation system powered by grunt-readme.
    • New section in docs about the notification systems.
    • More doc improvements coming in the future.
  • 7 November 2013 - 0.2.16
    • Avoid duplicate messages.
  • 3 November 2013 - 0.2.15
    • Fixed issue with OS X 10.9 Mavericks. Unfortunately Apple took away the ability to customize the icon.
  • 29 October 2013 - 0.2.14
    • Since grunt-contrib-watch can overwrite grunt's warn and fatal functions, we now watch writeln as well for warnings and fatals.
  • 26 August 2013 - 0.2.13
    • Added Grunt icon to notify-send.
  • 24 August 2013 - 0.2.12
    • Fix bug causing exception with Semver in Linux, thanks to @theefer.
    • Won't notify Aborted due to warnings. when there was already a more helpful notification.
    • More automated tests.
    • Travis support added.
    • Moved changelog to it's own file.
  • 18 August 2013 - 0.2.11
    • Added another directory Snarl could be installed to.
  • 18 August 2013 - 0.2.10
    • Added more information to the --debug output.
  • 18 August 2013 - 0.2.9
    • Add debug output. Use --debug to see it.
  • 17 August 2013 - 0.2.8
    • Fixed bug caused Grunt-Notify to not work in 32-bit windows.
    • Fixed bug that prevented Snarl from working if the task ended quickly from an error.
    • Removed defaults for how many notifications and how long notifications say on the screen for Snarl.
    • Replaced Nodeunit tests with Mocha tests.
  • 29 July 2013 - 0.2.7
    • Fixed bug that could prevent Growl from working.
  • 26 July 2013 - 0.2.5
  • 30 May 2013 - 0.2.4
    • Make notications more reliable. They should show up now even if Grunt exists from an error.
    • Fix problems with \n in a windows path becoming a new line, like c:\new.
    • Don't show too many jshint errors. By default only 5 jshint notifications, and that number is configurable.
  • 4 Apr 2013 - 0.2.3
    • Avoid problems when there's no stack trace on errors thanks to @joeybaker.
  • 1 Apr 2013 - 0.2.2
    • Fix bug in Notify-Send thanks to @jcoffin.
  • 1 Apr 2013 - 0.2.1
    • Fix dependencies.
  • 31 Mar 2013 - 0.2.0
    • Complete rewrite.
    • New support for Grunt in Windows.
    • Now parses JSLint errors to show them in notification.
    • Notification title will automatically use package.json name field or directory name.
    • No more subtitle option.
    • Title now includes the task that was running.
    • Better command line escaping including support for newline \n.
  • 17 Mar 2013 - 0.1.6
    • Code refactor to clean things up
  • 19 Feb 2013 - 0.1.4
    • Added Linux support thanks to @johnmccalla.
    • Listen for fatal errors.
    • Simplified options.
    • Default title is project title.
    • Show file name and line number if available.
  • 28 Dec 2012 - 0.1.0-0.1.3
    • First version