While beeing used to using Rakefile, Cakefile and Jakefile, they all had some convenient way of listing the available tasks.
Like
jake -T
jake db:dump # Dump the database
jake db:load # Populate the database
..etc.
or even filtering "jake -T dum", to only show "the "jake db:dump" task.
So, is there a way to do the same using grunt? I was thinking of maybe creating a default task that iterates the entire grunt config object and write it to stdout via console.log, but does someone know a better way?
Thanks.
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 tasks
Running "availabletasks" task
Deployment Tasks
doc => Build the documentation.
production => Build a complete distribution for production; stricter linting and a full browser test.
Development Tasks
default => 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With