diff --git a/CHANGELOG.md b/CHANGELOG.md index f062cec5..4fa3d65a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## v0.5.0 - Moving main Grunt Drupal Tasks library code from Gruntfile.js to bootstrap.js +- Adding integration with OS notification features with grunt-notify - Adding documentation for use with a continuous integration system - Many dependency updates - Other minor improvements diff --git a/CONFIG.md b/CONFIG.md index 238307f6..e6c8dd2e 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -230,6 +230,21 @@ This is an example of the settings for Drush tasks: **drush.make.args**: An array of arguments to pass to Drush for the make operation. +### Notify Settings + +This is an example of the settings for the notify feature: + +``` +{ + "notify": { + "threshold": 3 + } +} +``` + +**notify.threshold**: Minimum number of seconds a task must execute for a +notification to be triggered when the task ends. + ### Theme Settings This is an example of the settings for theme tasks: diff --git a/package.json b/package.json index b51c370a..33f17825 100644 --- a/package.json +++ b/package.json @@ -5,25 +5,26 @@ "main": "bootstrap.js", "dependencies": { "grunt": "~0.4.5", + "grunt-available-tasks": "~0.5.0", "grunt-composer": "~0.4.4", "grunt-contrib-clean": "~0.6.0", - "grunt-contrib-copy": "~0.7.0", "grunt-contrib-compass": "^1.0.1", + "grunt-contrib-compress": "~0.12.0", + "grunt-contrib-copy": "~0.7.0", "grunt-contrib-symlink": "~0.3.0", "grunt-contrib-watch": "~0.6.1", "grunt-drush": "~0.0.3", "grunt-mkdir": "~0.1.1", "grunt-newer": "~0.8.0", - "grunt-shell": "^1.1.1", + "grunt-notify": "git+https://github.com/grayside/grunt-notify.git#0.5.0", + "grunt-parallel": "^0.3.1", "grunt-parallel-behat": "~0.3.6", - "grunt-phplint": "~0.0.5", "grunt-phpcs": "git+https://github.com/grayside/grunt-phpcs.git#0.3.0", - "grunt-contrib-compress": "~0.12.0", + "grunt-phplint": "~0.0.5", "grunt-phpmd": "~0.1.0", - "time-grunt": "^1.0.0", - "grunt-parallel": "^0.3.1", - "grunt-available-tasks": "~0.5.0", - "lodash": "^2.4.1" + "grunt-shell": "^1.1.1", + "lodash": "^2.4.1", + "time-grunt": "^1.0.0" }, "keywords": [ "build", @@ -33,6 +34,6 @@ ], "repository": { "type": "git", - "url" : "https://github.com/phase2/grunt-drupal-tasks.git" + "url": "https://github.com/phase2/grunt-drupal-tasks.git" } } diff --git a/tasks/notify.js b/tasks/notify.js new file mode 100644 index 00000000..df28983b --- /dev/null +++ b/tasks/notify.js @@ -0,0 +1,29 @@ +module.exports = function(grunt) { + + /** + * Define "notify" tasks. + */ + if (grunt.option('quiet') || process.env.GRUNT_DRUPAL_QUIET) { + return; + } + + grunt.loadNpmTasks('grunt-notify'); + var guessProjectName = require('grunt-notify/lib/util/guessProjectName'); + + grunt.config('notify_hooks', { + options: { + // title needs to be reset to the same as the grunt-notify default because + // the guessing mechanism thinks that grunt-drupal-tasks is the project. + title: guessProjectName(), + // Only trigger success messages if the process has taken longer than the + // configured notifyThreshold. + success: true, + threshold: grunt.config.get('config.notify.threshold') || 10, + duration: 5 + } + }); + + // This is required if you use any options. + grunt.task.run('notify_hooks'); + +};