Skip to content

Commit 1dd71d8

Browse files
committed
Refactor configured_target/1 to be consistent with configured_version/1
1 parent 913df53 commit 1dd71d8

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

lib/tailwind.ex

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,26 @@ defmodule Tailwind do
142142
end
143143

144144
@doc """
145-
Returns the configured tailwind target. By default, it is automatically detected
146-
based on the globally configured version.
145+
Returns the configured tailwind target.
146+
147+
By default, it is automatically detected based on `configured_version/0`.
147148
"""
148149
def configured_target do
149-
configured_target(configured_version())
150+
target_for_version(configured_version())
151+
end
152+
153+
@doc """
154+
Returns the configured tailwind target for the given `profile`.
155+
156+
By default, it is automatically detected based on `configured_version/1`.
157+
"""
158+
def configured_target(profile) when is_atom(profile) do
159+
profile
160+
|> configured_version()
161+
|> target_for_version()
150162
end
151163

152-
defp configured_target(version) when is_binary(version) do
164+
defp target_for_version(version) when is_binary(version) do
153165
Application.get_env(:tailwind, :target, system_target(version))
154166
end
155167

@@ -185,7 +197,7 @@ defmodule Tailwind do
185197
end
186198

187199
defp default_bin_path(version) do
188-
name = "tailwind-#{configured_target(version)}-#{version}"
200+
name = "tailwind-#{target_for_version(version)}-#{version}"
189201

190202
if Code.ensure_loaded?(Mix.Project) do
191203
Path.join(Path.dirname(Mix.Project.build_path()), name)
@@ -510,6 +522,6 @@ defmodule Tailwind do
510522
defp get_url(base_url, version) do
511523
base_url
512524
|> String.replace("$version", version)
513-
|> String.replace("$target", configured_target(version))
525+
|> String.replace("$target", target_for_version(version))
514526
end
515527
end

0 commit comments

Comments
 (0)