-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pre-execution and post-execution "hooks" #542
Comments
It will be really useful to have hooks. I am trying to run some code using data I collected in a multitask after the multitask finishes. Right now there is no easy way |
We've talked about adding setup/teardown methods for multi tasks, this is most likely something we'll address in 0.5. |
Are those going to work like say, jasmine specs beforeEach and afterEach() ? |
@cowboy Edge use case : let's say I run some task with targets out of order: |
I agree and to add to that it would be cool to be able to pass data to the next task |
@jakub-g in your example, who defines the |
@chchrist what data would you pass? Would you pass it to the next multi task target, or the next completely separate task? What's your use case? |
@cowboy To the next completely separate task. That way if for example did in a previous task grunt.file.recurse and I need the same file list in the next task, I don't need to iterate again. To be more specific. I have developed a task that finds if your app has missing jasmine spec files in order to prevent code to be untested. Then I wanted to get that list, create the missing specs based on a template and populate my Specrunner.html. It is realy hard now to do that with a multitask. |
In 0.5 we're going to be emitting events to facilitate this sort of thing. If you want to see the direction we're headed, check out: If you need to persist data across tasks, check out our recommendation (under Storing task files) here: |
try https://github.com/kingback/grunt-task-hooker
|
Hello,
I have an idea of adding some way to define hooks that will be executed before Grunt starts and after it finishes.
Now I can achieve this by creating a task, say
gruntBeforeStart
andgruntAfterEnd
and then usegrunt.registerTask('fooHooked', 'gruntBeforeStart foo gruntAfterEnd')
but you can see it's not very handy and doesn't scale.I can think of adding a "magic" tasks -- empty by default -- which will be always executed, regardless of the way Grunt is invoked. The main rationale is to invoke Grunt with any set of tasks I like from the command line, and have the hooks take place as well -- without the need to list them explicitly.
Usage example: timer to execute the whole build time, number of files processed, whatever.
Looking forward to your comments.
The text was updated successfully, but these errors were encountered: