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

Feature: Explicit version check #100

Merged
merged 1 commit into from
Aug 12, 2024
Merged
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
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
Loading