Skip to content

Commit

Permalink
Add version check flag (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gigitsu authored Aug 12, 2024
1 parent a4133dd commit f729dc3
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions lib/tailwind.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ defmodule Tailwind do
* `:version` - the expected tailwind version
* `:version_check` - whether to perform the version check or not.
Useful when you manage the tailwind executable with an external
tool (eg. npm)
* `:cacerts_path` - the directory to find certificates for
https connections
Expand Down Expand Up @@ -68,28 +72,30 @@ defmodule Tailwind do

@doc false
def start(_, _) do
unless Application.get_env(:tailwind, :version) || Application.get_env(:tailwind, :path) do
Logger.warning("""
tailwind version is not configured. Please set it in your config files:
if Application.get_env(:tailwind, :version_check, true) do
unless Application.get_env(:tailwind, :version) do
Logger.warning("""
tailwind version is not configured. Please set it in your config files:
config :tailwind, :version, "#{latest_version()}"
""")
end
config :tailwind, :version, "#{latest_version()}"
""")
end

configured_version = configured_version()
configured_version = configured_version()

case bin_version() do
{:ok, ^configured_version} ->
:ok
case bin_version() do
{:ok, ^configured_version} ->
:ok

{:ok, version} ->
Logger.warning("""
Outdated tailwind version. Expected #{configured_version}, got #{version}. \
Please run `mix tailwind.install` or update the version in your config files.\
""")
{:ok, version} ->
Logger.warning("""
Outdated tailwind version. Expected #{configured_version}, got #{version}. \
Please run `mix tailwind.install` or update the version in your config files.\
""")

:error ->
:ok
:error ->
:ok
end
end

Supervisor.start_link([], strategy: :one_for_one)
Expand All @@ -103,10 +109,7 @@ defmodule Tailwind do
Returns the configured tailwind version.
"""
def configured_version do
default_version =
if Application.get_env(:tailwind, :path), do: bin_version(), else: latest_version()

Application.get_env(:tailwind, :version, default_version)
Application.get_env(:tailwind, :version, latest_version())
end

@doc """
Expand Down

0 comments on commit f729dc3

Please sign in to comment.