copier icon indicating copy to clipboard operation
copier copied to clipboard

feat: Allow tasks to run in two stages, "before" or "after" copy

Open bhuynhdev opened this issue 11 months ago • 0 comments

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.tasks function accept an additional argument stage
    • Pass this stage via extra_vars so that the rendering context knows which _stage we're in
    • Default tasks' condition to {{ _stage == 'after' }} so that the default behavior is post-copy tasks
  • In main.py: Change run_copy to execute tasks twice, before and after _render_template

bhuynhdev avatar Mar 22 '25 05:03 bhuynhdev