-
-
Notifications
You must be signed in to change notification settings - Fork 625
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 task hooks #667
Add task hooks #667
Conversation
I'm running into issues in VS Code where the Taskfile YAML Schema is complaining about the new Edit: Nevermind, found this ... I will link the pull request here when done |
Hi @tylermmorton, thanks for yet another PR. I see future in this PR, but I understand we need to discuss what we really want to do here before proceeding. The idea of wrapping setting like this into The The In a similar manner, the Regarding #204 you linked, the idea of a possible EDIT: Still about #204, not only running before, and also keeping state like declared functions and environment variables, etc. that would still be accessible inside tasks. So this is actually more than just a hook. This is the kind of feature where the input from user is very important. So if whoever is reading this would like to add thoughts, they're more than welcome! |
Hey @andreynering, thanks the feedback! :) I'd like to make the argument to keep I agree that I will say to implement and maintain a hook is much easier than other features, as a hook in the current implementation does not control the flow of or branch any of the task logic. Every new hook definition is roughly 12 lines of code, which could be reduced, especially all of the boilerplate within executor's -- I just read deeper into #204 and I guess I did not get far enough into the discussion to realize this PR does not cover that 😅 My bad. I do really like the idea of a global I can probably get some code in for this next time I'm able to pull up my IDE. I will take any notes I have to that issue thread instead of this PR. Would it be easier for you to fold that feature into this branch or should I add the implementation separately? |
This PR is in response to a series of issues: #141, #204 and #344. This code adds "hooks" as a feature, with the initial implementation containing 5 hooks. I've added unit tests to cover all of the new behavior, and additional documentation containing examples of each hook!
before_all
commands are called before a task starts executionafter_all
commands are called after a task completes, success or failureon_success
commands are called when a task completes successfullyon_failure
commands are called when a task fails due to an exit code other than 0on_skipped
commands are called when a task is skipped due to status, precondition or checksumHere is an example of the usage: