Multitask

John Lindquist
InstructorJohn Lindquist
Share this video with your friends

Social Share Links

Send Tweet
Published 10 years ago
Updated 5 years ago

Grunt Multitask allows you to write complex tasks that run multiple targets. In this lesson, John will show you how to use Multitask in your GruntJS builds.

John Lindquist: Registering multitasks allows you to either iterate through or choose just an individual task to run from a list.

I say, "grunt.registerMultiTask." Say "tasks" is the name of it. Then, in here, I will "grunt.log.writeln(this.target)."

That'll just be the name of the task. We configure something called "tasks" here, and we just have "one" and nothing.

Then we come down to the terminal, and we run grunt tasks. You can see that it logs out "one," because that is the name of that first task.

If we add "two" to this, I can run grunt tasks. You can see it runs "one," then "two."

I can also just run grunt tasks and target "one," and that'll only run "one," or "grunt tasks:two," and that will only run "two."

You can basically get the target and the data. We can say "target" plus some empty space plus "this.data."

In here, we want the data to be "first" and the data to be "second." Then we'll just add a third one for good measure, or "three" and "third."

If I go "grunt tasks," you can see it runs "one" first, "two" second, "three" third. Then I can run any of them that I want. "Tasks:three," and it'll run "three" third.

Basically, you're taking this task you wrote. You can pass in any of the data, "one, two, three," into your task, use the target and data to run this however you want.

egghead
egghead
~ 2 hours ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today