-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support new gleam build CLI that doesn't accept legacy dot argument
- Loading branch information
1 parent
356f7bb
commit e27dac4
Showing
1 changed file
with
17 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
defmodule Mix.Tasks.Compile.Gleam do | ||
use Mix.Task.Compiler | ||
|
||
@first_gleam_version_not_taking_build_arg "0.18.0-rc1" | ||
|
||
def run(_args) do | ||
case Mix.shell().cmd("gleam build .") do | ||
case Mix.shell().cmd(build_command()) do | ||
0 -> {:ok, []} | ||
status -> exit(status) | ||
end | ||
end | ||
|
||
defp build_command do | ||
if build_needs_arg?(), | ||
do: "gleam build .", | ||
else: "gleam build" | ||
end | ||
|
||
defp build_needs_arg? do | ||
{cmd_output, 0} = System.cmd("gleam", ["-V"]) | ||
<<"gleam "::utf8, active_version::binary>> = String.trim(cmd_output) | ||
|
||
comparison = Version.compare(active_version, @first_gleam_version_not_taking_build_arg) | ||
comparison == :lt | ||
end | ||
end |