copier
copier copied to clipboard
feat: Allow tasks to run in two stages, "before" or "after" copy
What
This PR looks to resolve https://github.com/copier-org/copier/issues/240 by allowing tasks to run in two stages, "before" or "after" copy, similar to how #1510 implemented pre-copy and post-copy migration tasks
How
- Make
Template.tasksfunction accept an additional argumentstage- Pass this
stageviaextra_varsso that the rendering context knows which_stagewe're in - Default tasks' condition to
{{ _stage == 'after' }}so that the default behavior is post-copy tasks
- Pass this
- In
main.py: Changerun_copyto execute tasks twice, before and after_render_template