Skip to content
Closed
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
19 changes: 16 additions & 3 deletions lib/tailwind.ex
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,15 @@ defmodule Tailwind do
Application.get_env(:tailwind, :path) || default_bin_path(version)
end

defp executable_suffix do
case :os.type() do
{:win32, _} -> ".exe"
_ -> ""
end
end

defp default_bin_path(version) do
name = "tailwind-#{target_for_version(version)}-#{version}"
name = "tailwind-#{target_for_version(version)}-#{version}#{executable_suffix()}"

if Code.ensure_loaded?(Mix.Project) do
Path.join(Path.dirname(Mix.Project.build_path()), name)
Expand Down Expand Up @@ -388,7 +395,7 @@ defmodule Tailwind do

case {:os.type(), arch, abi, :erlang.system_info(:wordsize) * 8} do
{{:win32, _}, _arch, _abi, 64} ->
"windows-x64.exe"
"windows-x64"

{{:unix, :darwin}, arch, _abi, 64} when arch in ~w(arm aarch64) ->
"macos-arm64"
Expand Down Expand Up @@ -548,9 +555,15 @@ defmodule Tailwind do
end

defp get_url(base_url, version) do
target =
case target_for_version(version) do
"windows-x64" -> "windows-x64.exe"
other -> other
end
Comment on lines +558 to +562

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work as well? So we hardcode windows in fewer places?

Suggested change
target =
case target_for_version(version) do
"windows-x64" -> "windows-x64.exe"
other -> other
end
target = target_for_version(version) <> executable_suffix()


base_url
|> String.replace("$version", version)
|> String.replace("$target", target_for_version(version))
|> String.replace("$target", target)
end

defp normalize_env(env) do
Expand Down