From f936a2abccb057ee1dcea99469cb833e52ef5f08 Mon Sep 17 00:00:00 2001 From: "Alt D. Soy" Date: Sun, 17 Nov 2024 07:06:54 +0100 Subject: [PATCH] handle truthy boolean for CI env variable --- lib/hex/state.ex | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/hex/state.ex b/lib/hex/state.ex index 114af5ee..4e004dd3 100644 --- a/lib/hex/state.ex +++ b/lib/hex/state.ex @@ -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}