Is there a way to pass an argument from a alias task like this into on of the calling tasks:
grunt.registerTask('taskA', ['taskB', 'taskC'])
grunt taskA:test
so that task taskB
and taskC
will be called with the parameter test
?
You can create a dynamic alias task like this:
grunt.registerTask('taskA', function(target) {
var tasks = ['taskB', 'taskC'];
if (target == null) {
grunt.warn('taskA target must be specified, like taskA:001.');
}
grunt.task.run.apply(grunt.task, tasks.map(function(task) {
return task + ':' + target;
}));
});
Here is the FAQ with another example in the Grunt docs: http://gruntjs.com/frequently-asked-questions#dynamic-alias-tasks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With