From e38580717f40eaa374376b81c4ffafbe4a3dd08e Mon Sep 17 00:00:00 2001 From: Grayside Date: Wed, 24 Dec 2014 22:34:38 -0800 Subject: [PATCH 1/3] Add support for popup notifications with --notify. --- package.json | 19 ++++++++++--------- tasks/notify.js | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 tasks/notify.js diff --git a/package.json b/package.json index b51c370a..410b21e2 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": "^0.4.1", + "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..4f13c655 --- /dev/null +++ b/tasks/notify.js @@ -0,0 +1,23 @@ +module.exports = function(grunt) { + + /** + * Define "notify" tasks. + */ + if (grunt.option('notify')) { + grunt.loadNpmTasks('grunt-notify'); + var guessProjectName = require('grunt-notify/lib/util/guessProjectName'); + + grunt.config('notify_hooks', { + options: { + enabled: true, + max_jshint_notifications: 5, + title: guessProjectName(), + success: true, + duration: 5 + } + }); + + // This is required if you use any options. + grunt.task.run('notify_hooks'); + } +}; From 320f5b652bbeb31c1c0b0e1cd1bf05cf668ea3f4 Mon Sep 17 00:00:00 2001 From: Grayside Date: Fri, 26 Dec 2014 22:24:28 -0800 Subject: [PATCH 2/3] Switch to default enable notifications with an elapsed time threshold. --- package.json | 2 +- tasks/notify.js | 36 +++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 410b21e2..33f17825 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "grunt-drush": "~0.0.3", "grunt-mkdir": "~0.1.1", "grunt-newer": "~0.8.0", - "grunt-notify": "^0.4.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-phpcs": "git+https://github.com/grayside/grunt-phpcs.git#0.3.0", diff --git a/tasks/notify.js b/tasks/notify.js index 4f13c655..361d2744 100644 --- a/tasks/notify.js +++ b/tasks/notify.js @@ -3,21 +3,27 @@ module.exports = function(grunt) { /** * Define "notify" tasks. */ - if (grunt.option('notify')) { - grunt.loadNpmTasks('grunt-notify'); - var guessProjectName = require('grunt-notify/lib/util/guessProjectName'); + if (grunt.option('quiet') || process.env.GRUNT_DRUPAL_QUIET) { + return; + } - grunt.config('notify_hooks', { - options: { - enabled: true, - max_jshint_notifications: 5, - title: guessProjectName(), - success: true, - duration: 5 - } - }); + 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('notifyThreshold') || 10, + duration: 5 + } + }); + + // This is required if you use any options. + grunt.task.run('notify_hooks'); - // This is required if you use any options. - grunt.task.run('notify_hooks'); - } }; From 430f27235f8c4946553a45186d08cea002378b4a Mon Sep 17 00:00:00 2001 From: Joe Turgeon Date: Tue, 30 Dec 2014 23:22:46 -0600 Subject: [PATCH 3/3] Adding documentation for the notify feature, and fixing grunt.config.get() syntax. --- CHANGELOG.md | 1 + CONFIG.md | 15 +++++++++++++++ tasks/notify.js | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) 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/tasks/notify.js b/tasks/notify.js index 361d2744..df28983b 100644 --- a/tasks/notify.js +++ b/tasks/notify.js @@ -18,7 +18,7 @@ module.exports = function(grunt) { // Only trigger success messages if the process has taken longer than the // configured notifyThreshold. success: true, - threshold: grunt.config('notifyThreshold') || 10, + threshold: grunt.config.get('config.notify.threshold') || 10, duration: 5 } });