Giter Site home page Giter Site logo

grunt-notify's Introduction

grunt-notify

Automatic desktop notifications for Grunt errors and warnings using Growl for OS X or Windows, Mountain Lion Notification Center, Snarl, or Notify-Send.

Growl for Mac and Windows

Growl: JSHint Growl: Nodeunit

OS X Notifcation Center

Notification Center: JSHint

Snarl for Windows

Snarl: Nodeunit

Notify-Send for Linux

Screenshot on loan. Can someone donate a new one?

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:

// Automatic notifications when tasks fail.
grunt.loadNpmTasks('grunt-notify');

That's all you need for automatic notifications.

Notification Center: JSHint Grow: JSHint

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

Showing Specfic Notifications

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

Growl: Custom Text Notification Center: Custom Text

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.

Terminal Notifier

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 Notifer from Eloy Durán. I've changed the default icon which is owned by Apple to the Grunt logo.

Doodle or Die

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!

Release History

  • 29 July 2013 - 0.2.7
  • Fixed bug that could prevent Growl from working.
  • 26 July 2013 - 0.2.5
  • Windows Snarl support thanks to @vohof and @FunkMonkey.
  • 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

grunt-notify's People

Contributors

dylang avatar jcoffin avatar joeybaker avatar johnmccalla avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.