Skip to content

Commit

Permalink
improvement: add an optional path argument to `find_and_update_or_cre…
Browse files Browse the repository at this point in the history
…ate_module/5`
  • Loading branch information
zachdaniel committed Jun 28, 2024
1 parent fd475c3 commit dd42d44
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/igniter/code/module.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ defmodule Igniter.Code.Module do
alias Igniter.Code.Common
alias Sourceror.Zipper

@doc "Find or create module"
def find_and_update_or_create_module(igniter, module_name, contents, updater) do
@doc "Finds a module and updates its contents wherever it is. If it does not exist, it is created with the provided contents."
def find_and_update_or_create_module(igniter, module_name, contents, updater, path \\ nil) do
igniter
|> Igniter.include_glob("lib/**/*.ex")
|> Map.get(:rewrite)
Expand Down Expand Up @@ -69,7 +69,7 @@ defmodule Igniter.Code.Module do
end
"""

Igniter.create_new_elixir_file(igniter, proper_location(module_name), contents)
Igniter.create_new_elixir_file(igniter, path || proper_location(module_name), contents)
end
end

Expand Down

0 comments on commit dd42d44

Please sign in to comment.