Chaining Tasks

So far we haven’t done anything with Grunt that we couldn’t do with Bash, PowerShell, Perl, Python, or any other scripting language. But Grunt offers the ability to create one task that fires off other tasks. Grunt refers to this as an alias.

To make a task like this we use registerTask and pass it an array of tasks instead of a callback function.

basics/kicking_tires/Gruntfile.js
 
grunt.registerTask(​'all'​, [​'default'​, ​'greet:Brian'​, ​'addNumbers:2:3'​]);

Notice that when we do this we pass these task names as strings, which means we can pass arguments as well.

We’ve called this task all, but if we renamed it to default we’d be able to run this task by running grunt with no arguments. The default task is commonly used to run the test suite for a project.

Now let’s look at one more basic but really important piece: adding a little documentation to our tasks.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.139.245