Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I invoke other tasks from my custom task *before* my task code runs?

I'm trying to create a custom task in grunt that automatically invokes its "prerequisites". I'm not sure on how to do that. The Grunt.js docs show this example:

grunt.registerTask('foo', 'My "foo" task.', function() {
  // Enqueue "bar" and "baz" tasks, to run after "foo" finishes, in-order.
  grunt.task.run('bar', 'baz');
  ... // Other stuff here
});

I don't want to "enqueue bar and baz after foo", I want to execute them right there, where the grunt.task.run line is, so they get executed before my "Other stuff".

How do I do that?

like image 564
kikito Avatar asked Feb 26 '13 22:02

kikito


People also ask

How do I run a task in C#?

To start a task in C#, follow any of the below given ways. Use a delegate to start a task. Task t = new Task(delegate { PrintMessage(); }); t. Start();

Which of the following interface is used to implement a custom task in MS build?

An MSBuild custom task is a class that implements the ITask interface.


1 Answers

I think your only way to do it currently would be via creating and additional task

grunt.registerTask('fooTask', 'My "foo" task.', function() {
  grunt.task.requires('bar'); // make sure bar was run and did not fail
  grunt.task.requires('baz'); // make sure bar was run and did not fail
  ... // Other stuff here
});

grunt.registerTask('foo', 'My "foo" sequence.', ['bar', 'baz', 'fooTask']);
like image 78
Jerome WAGNER Avatar answered Nov 04 '22 19:11

Jerome WAGNER