grunt
grunt copied to clipboard
Execute another task within my task (without queueing the other one)
Is there an API for executing another task from within my task?
I'd like to execute another task from within my own, then perform some cleanup tasks afterwards even if the other task failed.
Tasks like grunt-newer currently have to resort to tricks where they queue the other task to run immediately after themselves. There are workarounds to ensure that, even if the other, queued task fails, post-task cleanup actions will still occur. This could be avoided with a simple API to execute another task.
Possible API:
grunt.task.runTaskNow(taskName, arguments, /*optional*/ config);
You could use grunt-force. I don't see the real benefit of adding this. It will only add extra complexity to your grunt configuration.
I'm thinking of this as a building block to be used by tasks such as grunt-force and grunt-newer. Currently grunt's core doesn't expose any sort of API for doing this cleanly, and yet grunt-force and grunt-newer demonstrate the need for this API to exist.
EDIT: hit enter too soon; finished my comment.
FWIW, this is an issue I would like to address. I've started working on an RFC related, to make tasks run standalone and will cross post here once I've opened the PR for it here: https://github.com/gruntjs/rfcs