Closed warsus closed 4 years ago
@warsus Thanks for reporting this! It took a little work to recreate, but I see the issue.
It seems like a fix for this should include an integration test that changes the line endings on the entire phoenix app before running the generator. This test would probably go in test/mix/tasks/phx_gen_auth/integration_tests/default_app_test.exs
and look something like this:
test "single project with windows line endings", %{test_app_path: test_app_path} do
convert_project_line_endings(test_app_path, "\r\n") # Function to be written
mix_run!(~w(phx.gen.auth Accounts Users user), cd: test_app_path)
mix_deps_get_and_compile(test_app_path)
assert_no_compilation_warnings(test_app_path)
assert_mix_test_succeeds(test_app_path)
end
I appreciate your PR and I'm happy to help. I think this line ending issue is something that needs to be solved anywhere we're doing code injection.
@aaronrenner That seems to be a thorough approach to this issue. I'm a little bit busy right now, so don't feel hindered by my pull request if you get the chance to work on this. For me personally a quick fix for this bug would be good as i'm not so picky about my newline style. :) I found this slightly related issue for gofmt an interesting read: https://github.com/golang/go/issues/16355
Thank for the reply!
Hi, cool project!
I ran this on windows and got Mix.raise(~s[Could not find "use Mix.Config" or "import Config" in #{inspect(file)}]) even though my test.exs has the former. I suppose because it is "use Mix.Config\r\n" in my case which will not match "use Mix.Config\n".