[Grunt] Multitask, this.target, this.data, registerMultiTask()
When a multi task is run, Grunt looks for a property of the same name in the Grunt configuration. Multi-tasks can have multiple configurations, defined using arbitrarily named "targets."
grunt.registerMultiTask(taskName, [description, ] taskFunction)
Read More: http://gruntjs.com/creating-tasks#multi-tasks
GruntFile.js
/** * Created by Answer1215 on 9/4/2014. */ module.exports = function(grunt){ grunt.initConfig({ tasks:{ one: "first", two: "second", three:"third" } }) grunt.registerMultiTask("tasks",function(){ grunt.log.writeln(this.target+ ", "+ this.data) }) }
In cmd, you can type:
grunt tasks: three
grunt tasks
The result:
C:\Users\Answer1215\WebstormProjects\angular\grunt_demo2>grunt tasks:three Running "tasks:three" (tasks) task three, third Done, without errors. C:\Users\Answer1215\WebstormProjects\angular\grunt_demo2>grunt tasks Running "tasks:one" (tasks) task one, first Running "tasks:two" (tasks) task two, second Running "tasks:three" (tasks) task three, third Done, without errors.

浙公网安备 33010602011771号