89

I'm trying to work out how to print a list of all available grunt tasks. With rake it would be:

$ rake -T

What's the equivalent for grunt? e.g.

$ grunt -T

  • concat
  • jasmine
  • minify

2 Answers 2

174

grunt --help lists available tasks.

4
  • 4
    ha! I completely missed that, saw the top section of commands but didn't notice the tasks were listed at the bottom...
    – opsb
    Commented Feb 21, 2013 at 20:09
  • 2
    @tJener how to you list the tasks of a multi task: grunt multi:task0, multi:task1, etc.? Commented Jun 15, 2014 at 13:56
  • on a sidenote, a related interesting dicussion about being able to create a public or private task here: github.com/gruntjs/grunt/issues/741
    – Michahell
    Commented Sep 24, 2014 at 22:59
  • 3
    @CiroSantilli I maintain a separate task listing module github.com/ben-eb/grunt-available-tasks which prints a task list, with multi-task targets, and without all of the noise that grunt --help generates. You might like to use it for now as a stop-gap, bearing in mind that it's been over a year since I first released it and still no option within grunt to hide tasks, etc.
    – Ben
    Commented Dec 15, 2014 at 11:03
4

Workaround for the list in sh/bash in case you need to trigger something and can't modify the original code:

grunt -h --no-color | sed -n '/^Available tasks/,/^$/ {s/^  *\([^ ]\+\)  [^ ]\+.*$/\1/p}'
3
  • 1
    Sed program doesn't work: "/^Available tasks/,/^$/ ...": bad flag in substitute command: '}'
    – gotofritz
    Commented Feb 2, 2016 at 17:14
  • @gotofritz did you use single quotes? Double quotes have a different meaning check you sed documention otherwise. In case you use MacOs, it uses a different version of sed with a slightly different syntax.
    – estani
    Commented Feb 3, 2016 at 8:51
  • Yes, I was on OS X. But don't worry about it, I hardly use grunt these days anyway :-)
    – gotofritz
    Commented Feb 5, 2016 at 17:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.