3

So I mean something like:

grunt.registerTask('default', ['default']); // CLI: grunt
grunt.registerTask('serve', ['serve']); // CLI: grunt serve
grunt.registerTask('test', ['test']); // CLI: grunt test

And then I want just one task which runs the 3 of those in one call, like, if I type into the cmd "grunt tasks", it runs any tasks I want such as default, serve or test in the order I specify, etc.

Can this be done? The docs arent very clear (maybe its my dyspraxia, but it just doesnt read well to me).

Cheers,

-- SD

  • 1
    [registerTask](http://gruntjs.com/creating-tasks) takes a taskList as parameter if that's you want to know (the arrays you have) – Hacketo Apr 08 '16 at 12:47

1 Answers1

1

Yes, you can very easily.

From the documentation:

You can configure Grunt to run one or more tasks by default by defining a default task. In the following example, running grunt at the command line without specifying a task will run the uglify task. This is functionally the same as explicitly running grunt uglify or even grunt default. Any number of tasks (with or without arguments) may be specified in the array.

The key part of the excerpt above is bolded.

For example, create a task called runAllThree, and specify all three tasks you'd like to run inside of the array.

grunt.registerTask('runAllThree', ['default', 'serve', 'test']);

njtman
  • 2,160
  • 1
  • 19
  • 32
  • See, that is much clearer, thanks! WIll try this when I get back to the house in half an hour! –  Apr 08 '16 at 12:52
  • 1
    Glad I can help @SkullDev . Read up on "Alias Tasks" here http://gruntjs.com/creating-tasks – njtman Apr 08 '16 at 12:57