diff --git a/.travis.yml b/.travis.yml index 326b27e5..90c6c75f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ install: - npm install -g mocha script: - export PATH=$PATH:`pwd`/bin + - grunt help - grunt --timer - echo "Example fully built disk usage"; du -chs . - grunt drush:liteinstall --timer diff --git a/bootstrap.js b/bootstrap.js index 239155fc..3f57ccea 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -53,4 +53,6 @@ module.exports = function(grunt) { if (grunt.option('timer')) { require('time-grunt')(grunt); } + + require('grunt-log-headers')(grunt); }; diff --git a/package.json b/package.json index 1c64f390..5a07d76b 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "grunt-contrib-symlink": "0.3.0", "grunt-contrib-watch": "0.6.1", "grunt-drush": "0.0.6", + "grunt-log-headers": "^1.0.1", "grunt-mkdir": "0.1.2", "grunt-newer": "1.1.0", "grunt-notify": "git+https://github.com/grayside/grunt-notify.git#0.5.0", diff --git a/tasks/help.js b/tasks/help.js index 6e038f2f..0f28e369 100644 --- a/tasks/help.js +++ b/tasks/help.js @@ -7,7 +7,6 @@ module.exports = function(grunt) { * Provides an overview of intended and useful grunt tasks. */ - grunt.loadNpmTasks('grunt-available-tasks'); var Help = require('../lib/help')(grunt); Help.add({ @@ -16,7 +15,75 @@ module.exports = function(grunt) { description: 'The default build process that executes when "grunt" runs, which includes verifying dependencies and assembling the build directory.' }); + // Specify that only configured help entries should be displayed. grunt.config('availabletasks.help.options.filter', 'include'); - grunt.registerTask('help', ['availabletasks:help']); + // Suppress task headings for help to keep it lean. + grunt.config('help.options.gruntLogHeader', false); + grunt.config('availabletasks.help.options.gruntLogHeader', false); + grunt.config('help-after.options.gruntLogHeader', false); + + grunt.registerTask('help', 'Output grunt-drupal-tasks specialized help.', function() { + var gdt = {}; + var gruntHelp = require('grunt/lib/grunt/help'); + var process = function(queue) { queue.forEach(function(cb) { cb(); }); }; + + gdt.cleanOptions = function() { + for (var i in gruntHelp._options) { + item = gruntHelp._options[i]; + if (item[0] == '--base' || item[0] == '--gruntfile' || item[0] == '--tasks' || item[0] == '--npm') delete gruntHelp._options[i]; + if (item[0] == '--help, -h') gruntHelp._options[i][1] = 'Display the default Grunt help text.'; + } + }; + + gdt.header = function() { + grunt.log.writeln('Used with Grunt Drupal Tasks (v' + require('../package.json').version + ')'); + grunt.log.writeln().writeln('To display this help, run `grunt help`'); + }; + + gdt.options = function() { + var options = [ + [ '--quiet', 'Suppress desktop notifications.' ], + [ '--timer', 'Output task execution timing info.' ], + [ '--concurrency', 'Override the dynamic concurrency parameter used by Drush Make.' ] + ]; + gruntHelp.table(options); + }; + + gdt.tasks = function() { + grunt.loadNpmTasks('grunt-available-tasks'); + grunt.task.run('availabletasks:help', 'help-after'); + }; + + gdt.footer = function() { + grunt.log.writeln('For help with Grunt Drupal Tasks, see ' + require('../package.json').homepage); + }; + + // Dispatch to grunt tasks is asynchronous, in order to display text after + // dispatching to availabletasks we need a dedicated task so grunt's internal + // task sequencing will ensure the proper order of execution. + grunt.registerTask('help-after', 'Generate a footer to follow primary help text.', function() { + var queue = [ + gruntHelp.footer, + gdt.footer + ]; + + process(queue); + }); + + var queue = [ + gruntHelp.initOptions, + gdt.cleanOptions, + gruntHelp.initWidths, + gruntHelp.header, + gdt.header, + gruntHelp.usage, + gruntHelp.options, + gdt.options, + gruntHelp.optionsFooter, + gdt.tasks + ]; + + process(queue); + }); }; diff --git a/tasks/notify.js b/tasks/notify.js index df28983b..ad41f1c7 100644 --- a/tasks/notify.js +++ b/tasks/notify.js @@ -19,7 +19,9 @@ module.exports = function(grunt) { // configured notifyThreshold. success: true, threshold: grunt.config.get('config.notify.threshold') || 10, - duration: 5 + duration: 5, + // Supposed to suppress notify_hooks log header, but not working. + gruntLogHeader: false } }); diff --git a/tasks/theme.js b/tasks/theme.js index d078d723..e8e60d30 100644 --- a/tasks/theme.js +++ b/tasks/theme.js @@ -86,7 +86,7 @@ module.exports = function(grunt) { Help.add({ task: 'compile-theme', group: 'Asset & Code Compilation', - description: 'Run compilers for the theme, such as Compass.' + description: 'Run compilers for all themes (such as Compass).' }); }