Grunt (node) - How to show available tasks? Grunt (node) - How to show available tasks? javascript javascript

Grunt (node) - How to show available tasks?


grunt --help lists available tasks, as per following answer.

Example output

.....Available tasks             clean  Clean files and folders. *                                              jade  Compile jade templates. *                                         web_server  A Web Server similar to Python's SimpleHTTPServer, with                    Cross-Origin Resource Sharing and No-Cache options. *   


As far as I know the only way (obviously without hacks) to show the available tasks is using the -h or --help option.

As you can see in grunt-cli source they clearly take care about only -h (help), -V (version), and -v (verbose) options.

So, I think that currently you have to create your own custom task to reach your goal.


There is a better way! I'm currently working on a separate plugin, grunt-available-tasks to achieve this functionality. Add it to your project with:

npm install grunt-available-tasks --save-dev

Then run grunt availabletasks to get a list of your tasks. You may want to alias this with tasks to save some typing:

grunt.registerTask('tasks', ['availabletasks']);

Then, with some configuration you can get lists like this one:

$ grunt tasksRunning "availabletasks" taskDeployment Tasksdoc                => Build the documentation.production         => Build a complete distribution for production; stricter linting and a full browser test.Development Tasksdefault            => Build a development distribution.watch               > Run predefined tasks whenever watched files change.Done, without errors.

You can filter, group and sort tasks using a configuration object in your Gruntfile. A comprehensive list of options is available in the README.