Open dkarter opened 1 day ago
Thanks for the report! Tracked the bug down to the private should_move_file_to/5
inside Igniter.Project.Module
, but can't keep going deeper at the moment. Should be an easy enough fix once I have a bit more time.
This may be a bit more difficult to address than I thought.
When creating a file, Igniter.Project.Module.proper_location/3
is used to ultimately determine where the file should go. Extensions like Igniter.Extensions.Phoenix
can "hook in" here in order to provide more application-architecture-aware information. proper_location/3
also knows about your Igniter config, which can be used to determine whether a module Foo
should live at lib/foo.ex
or lib/foo/foo.ex
(a user preference).
Looking through the code, it seems like proper_location/3
doesn't actually know about the original path for the file at all; it uses the module name and a sort of enum to determine what "kind" of file it is: :source_folder | {:source_folder, path} | :test | :test_support
. After it's determined that, it decides what the file extension should be.
This means we likely need an API change to proper_location
in order to handle this. For instance:
Igniter.Project.Module.proper_location(igniter, Some.Module, :source_folder)
# perhaps changes to
Igniter.Project.Module.proper_location(igniter, Some.Module, type: :source_folder, extension: ".ex")
where the extension is inferred if it's nil
or, in the case of creating a new file, uses whatever extension was originally passed.
Describe the bug
When calling
The file path unexpectedly changes to
.ex
To Reproduce
Then run
mix example
Expected behavior
The file gets written to the path the user provides
** Runtime
Additional context
We are co-locating tests next to the implementation files e.g.
lib/something/foo.ex
lib/something/foo_test.exs
and have created a generator to simplify creating business logic files and their test stubs. When we try to create the test it gets renamed to.ex
which adds work to rename it back toexs
.Happy to provide a more in depth explanation of our use case if you want.