Skip to content

Commit

Permalink
handle truthy boolean for CI env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
altdsoy committed Nov 17, 2024
1 parent eec7a26 commit f936a2a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/hex/state.ex
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ defmodule Hex.State do
ci: %{
env: ["CI"],
default: false,
fun: {__MODULE__, :to_boolean}
fun: {__MODULE__, :to_truthy_boolean}
}
}

Expand Down Expand Up @@ -315,6 +315,15 @@ defmodule Hex.State do
def to_boolean("TRUE"), do: {:ok, true}
def to_boolean(_), do: :error

def to_truthy_boolean(value) do
value
|> to_boolean()
|> then(fn
:error -> {:ok, true}
boolean -> boolean
end)
end

def to_integer(nil), do: {:ok, nil}
def to_integer(""), do: {:ok, nil}
def to_integer(integer) when is_integer(integer), do: {:ok, integer}
Expand Down

0 comments on commit f936a2a

Please sign in to comment.