@@ -7,7 +7,6 @@ module.exports = function(grunt) {
77 * Provides an overview of intended and useful grunt tasks.
88 */
99
10- grunt . loadNpmTasks ( 'grunt-available-tasks' ) ;
1110 var Help = require ( '../lib/help' ) ( grunt ) ;
1211
1312 Help . add ( {
@@ -16,7 +15,75 @@ module.exports = function(grunt) {
1615 description : 'The default build process that executes when "grunt" runs, which includes verifying dependencies and assembling the build directory.'
1716 } ) ;
1817
18+ // Specify that only configured help entries should be displayed.
1919 grunt . config ( 'availabletasks.help.options.filter' , 'include' ) ;
2020
21- grunt . registerTask ( 'help' , [ 'availabletasks:help' ] ) ;
21+ // Suppress task headings for help to keep it lean.
22+ grunt . config ( 'help.options.gruntLogHeader' , false ) ;
23+ grunt . config ( 'availabletasks.help.options.gruntLogHeader' , false ) ;
24+ grunt . config ( 'help-after.options.gruntLogHeader' , false ) ;
25+
26+ grunt . registerTask ( 'help' , 'Output grunt-drupal-tasks specialized help.' , function ( ) {
27+ var gdt = { } ;
28+ var gruntHelp = require ( 'grunt/lib/grunt/help' ) ;
29+ var process = function ( queue ) { queue . forEach ( function ( cb ) { cb ( ) ; } ) ; } ;
30+
31+ gdt . cleanOptions = function ( ) {
32+ for ( var i in gruntHelp . _options ) {
33+ item = gruntHelp . _options [ i ] ;
34+ if ( item [ 0 ] == '--base' || item [ 0 ] == '--gruntfile' || item [ 0 ] == '--tasks' || item [ 0 ] == '--npm' ) delete gruntHelp . _options [ i ] ;
35+ if ( item [ 0 ] == '--help, -h' ) gruntHelp . _options [ i ] [ 1 ] = 'Display the default Grunt help text.' ;
36+ }
37+ } ;
38+
39+ gdt . header = function ( ) {
40+ grunt . log . writeln ( 'Used with Grunt Drupal Tasks (v' + require ( '../package.json' ) . version + ')' ) ;
41+ grunt . log . writeln ( ) . writeln ( 'To display this help, run `grunt help`' ) ;
42+ } ;
43+
44+ gdt . options = function ( ) {
45+ var options = [
46+ [ '--quiet' , 'Suppress desktop notifications.' ] ,
47+ [ '--timer' , 'Output task execution timing info.' ] ,
48+ [ '--concurrency' , 'Override the dynamic concurrency parameter used by Drush Make.' ]
49+ ] ;
50+ gruntHelp . table ( options ) ;
51+ } ;
52+
53+ gdt . tasks = function ( ) {
54+ grunt . loadNpmTasks ( 'grunt-available-tasks' ) ;
55+ grunt . task . run ( 'availabletasks:help' , 'help-after' ) ;
56+ } ;
57+
58+ gdt . footer = function ( ) {
59+ grunt . log . writeln ( 'For help with Grunt Drupal Tasks, see ' + require ( '../package.json' ) . homepage ) ;
60+ } ;
61+
62+ // Dispatch to grunt tasks is asynchronous, in order to display text after
63+ // dispatching to availabletasks we need a dedicated task so grunt's internal
64+ // task sequencing will ensure the proper order of execution.
65+ grunt . registerTask ( 'help-after' , 'Generate a footer to follow primary help text.' , function ( ) {
66+ var queue = [
67+ gruntHelp . footer ,
68+ gdt . footer
69+ ] ;
70+
71+ process ( queue ) ;
72+ } ) ;
73+
74+ var queue = [
75+ gruntHelp . initOptions ,
76+ gdt . cleanOptions ,
77+ gruntHelp . initWidths ,
78+ gruntHelp . header ,
79+ gdt . header ,
80+ gruntHelp . usage ,
81+ gruntHelp . options ,
82+ gdt . options ,
83+ gruntHelp . optionsFooter ,
84+ gdt . tasks
85+ ] ;
86+
87+ process ( queue ) ;
88+ } ) ;
2289} ;
0 commit comments