ash-project / igniter

A code generation and project patching framework.
https://hexdocs.pm/igniter/readme.html
MIT License
189 stars 23 forks source link

`mix igniter.move_files` with `:inside_matching_folder` always flips module location #159

Closed nikitalocalhost closed 1 day ago

nikitalocalhost commented 5 days ago

Describe the bug When using module_location: :inside_matching_folder and project module location is outside folder ,mix igniter.move_files moves modules to correct location, and when project module location is inside folder it moves modules back outside

To Reproduce

2024-11-21-141817_1041x759_scrot

Repo: https://github.com/nikitalocalhost/igniter-move-files-bug-demo

Expected behavior After first mix igniter.move_files repeating it would not propose to move files

Runtime

nikitalocalhost commented 5 days ago

For some reason there's two evocations of Igniter.Project.Module.move_files/2 per mix igniter.move_files: one with [move_all?: true], which resolves correctly, and one with [], which i think overwrites location

Edit: second evocation from Igniter.prepare_for_write/1, which is used in Igniter.do_or_dry_run/1, which is used in Igniter.Mix.Task.run/1

nikitalocalhost commented 5 days ago

When I add move_all?: true to evocation of Igniter.Project.Module.move_files/2 in Igniter.prepare_for_write/1 issue is solved

zachallaun commented 5 days ago

I think it comes down to this boolean logic here. I admit that I'm not fully following it, so we may need to wait for @zachdaniel to return from vacation! (Which I believe is soonish.)