Skip to content

Commit

Permalink
fix: handle single length list config paths that already exist
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Jan 27, 2025
1 parent 4547901 commit 9f3d4c2
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions lib/igniter/project/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,27 @@ defmodule Igniter.Project.Config do
:error

{:ok, zipper} ->
with {:ok, zipper} <- Igniter.Code.Function.move_to_nth_argument(zipper, 2),
{:ok, zipper} <- Igniter.Code.Keyword.put_in_keyword(zipper, path, value, updater) do
{:ok, zipper}
if path == [] do
case Igniter.Code.Function.move_to_nth_argument(zipper, 2) do
{:ok, zipper} ->
if updater do
updater.(zipper)
else
{:ok, Igniter.Code.Common.replace_code(zipper, value)}
end

_ ->
:error
end
else
_ ->
:error
with {:ok, zipper} <- Igniter.Code.Function.move_to_nth_argument(zipper, 2),
{:ok, zipper} <-
Igniter.Code.Keyword.put_in_keyword(zipper, path, value, updater) do
{:ok, zipper}
else
_ ->
:error
end
end
end
end
Expand Down

0 comments on commit 9f3d4c2

Please sign in to comment.