-
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement: handle igniter not being compiled, and make it optional
- Loading branch information
1 parent
4a65000
commit 517201e
Showing
10 changed files
with
1,639 additions
and
1,457 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
defmodule Ash.Igniter do | ||
@moduledoc "Codemods and utilities for working with Ash & Igniter" | ||
if Code.ensure_loaded?(Igniter) do | ||
defmodule Ash.Igniter do | ||
@moduledoc "Codemods and utilities for working with Ash & Igniter" | ||
|
||
@doc "Adds a codegen task, or updates the name to be `<old_name>_and_name`" | ||
def codegen(igniter, name) do | ||
has_codegen? = | ||
Enum.any?(igniter.tasks, fn | ||
{"ash.codegen", _args} -> | ||
true | ||
@doc "Adds a codegen task, or updates the name to be `<old_name>_and_name`" | ||
def codegen(igniter, name) do | ||
has_codegen? = | ||
Enum.any?(igniter.tasks, fn | ||
{"ash.codegen", _args} -> | ||
true | ||
|
||
_ -> | ||
false | ||
end) | ||
_ -> | ||
false | ||
end) | ||
|
||
if has_codegen? do | ||
Map.update!(igniter, :tasks, fn tasks -> | ||
Enum.map(tasks, fn | ||
{"ash.codegen", [old_name | rest]} -> | ||
{"ash.codegen", [old_name <> "_and_#{name}" | rest]} | ||
if has_codegen? do | ||
Map.update!(igniter, :tasks, fn tasks -> | ||
Enum.map(tasks, fn | ||
{"ash.codegen", [old_name | rest]} -> | ||
{"ash.codegen", [old_name <> "_and_#{name}" | rest]} | ||
|
||
task -> | ||
task | ||
task -> | ||
task | ||
end) | ||
end) | ||
end) | ||
else | ||
Igniter.add_task(igniter, "ash.codegen", [name]) | ||
else | ||
Igniter.add_task(igniter, "ash.codegen", [name]) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.