grunt
grunt copied to clipboard
Pass callback to grunt.task.run
grunt.task.run
runs a task after another has finished. However I need to run a task from within a task and process things after the other task has finished. An API like this would be beautiful:
var done = this.async();
grunt.task.run('some-task', function() {
// do things after 'some-task' finished
done();
});
I couldn't find a way to do that with the current API.
EDIT:
What I currently do to solve this problem. I use another internal task which runs before/after my some-task
. This internal task is only needed to set some dynamic config and shouldn't be called manually. Usage looks like this:
grunt.task.run('internal-task', 'some-task');
// or
grunt.task.run('some-task', 'internal-task');
+1
FWIW, something similar is planned for v0.5. See #542
+1
+1
+1
:+1:
//cc @cowboy
+1
+1
+1
+1
:+1: +1
+1
Yes, please. Gimme two.
+1
+1
+1
+!
Please just hit "Subscribe" rather than reply with "+1" which spams everyone following the thread, thanks.
+1
+1
+1
there should also be an argument with the task completion status code in this "finalize callback" and a possitibility to to avoid interruption of the task flow;
grunt.task.run('some-task', function (status) {
console.log('some-task completed with status: ' + status);
return true; // force continue
});
+1
+1
Please just click "Subscribe" on the right instead of replying to +1 (which pings all subscribers), thanks.
I just now finished making grunt-anon-tasks
to solve this problem.
grunt.task
.run("some-task")
.then(function () {
// do stuff after "some-task" completes, but before "other-task" begins
})
.run("other-task")
Check out the repo to learn more.
+1
+1
:+1:
+1