mirror of
https://github.com/plausible/analytics.git
synced 2024-11-26 11:44:03 +03:00
Make Plausible.ce? and Plausible.ee? into functions (#4158)
* make Plausible.ce? and Plausible.ee? into functions * Fix phash and predicate order to make dialyzer trick working again --------- Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
This commit is contained in:
parent
79349730a0
commit
55dfe4cea7
@ -20,23 +20,14 @@ defmodule Plausible do
|
||||
do_on_ce(clauses)
|
||||
end
|
||||
|
||||
defmacro ee?() do
|
||||
ee? = Mix.env() not in @ce_builds
|
||||
|
||||
# Tricking dialyzer as per:
|
||||
# :erlang.phash2(1, 1) == 0 tricks dialyzer as per:
|
||||
# https://github.com/elixir-lang/elixir/blob/v1.12.3/lib/elixir/lib/gen_server.ex#L771-L778
|
||||
quote do
|
||||
:erlang.phash2(1, 1) == 0 and unquote(ee?)
|
||||
end
|
||||
end
|
||||
|
||||
defmacro ce?() do
|
||||
ce_build? = Mix.env() in @ce_builds
|
||||
ee? = Mix.env() not in @ce_builds
|
||||
def ee?, do: :erlang.phash2(1, 1) == 0 and unquote(ee?)
|
||||
|
||||
quote do
|
||||
unquote(ce_build?)
|
||||
end
|
||||
end
|
||||
ce? = Mix.env() in @ce_builds
|
||||
def ce?, do: :erlang.phash2(1, 1) == 0 and unquote(ce?)
|
||||
|
||||
defp do_on_ce(do: block) do
|
||||
do_on_ee(do: nil, else: block)
|
||||
|
Loading…
Reference in New Issue
Block a user