Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle truthy boolean for CI env variable #1055

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
handle truthy boolean for CI env variable
altdsoy committed Nov 17, 2024
commit f936a2abccb057ee1dcea99469cb833e52ef5f08
11 changes: 10 additions & 1 deletion lib/hex/state.ex
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ defmodule Hex.State do
ci: %{
env: ["CI"],
default: false,
fun: {__MODULE__, :to_boolean}
fun: {__MODULE__, :to_truthy_boolean}
}
}

@@ -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}