Skip to content

Commit

Permalink
Fix bad list concatenation.
Browse files Browse the repository at this point in the history
If the `unless` block didn't run, the code would attempt to append `nil` to
the `opts` list (because `nil` is the default "else" value).
  • Loading branch information
jparise committed Feb 11, 2016
1 parent 638eb15 commit 8d4943c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/mix/tasks/compile.thrift.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ defmodule Mix.Tasks.Compile.Thrift do
end
unless(Enum.empty?(stale_files), do: File.mkdir_p!(output_dir))

options = get_thrift_options(output_dir, thrift_options)
options = build_options(output_dir, thrift_options)
Enum.each stale_files, &generate(&1, options)
end

Expand All @@ -70,11 +70,11 @@ defmodule Mix.Tasks.Compile.Thrift do
Enum.empty?(targets) || Mix.Utils.stale?([thrift_file], targets)
end

defp get_thrift_options(output_dir, user_options) do
defp build_options(output_dir, user_options) do
opts = ~w[--out] ++ [output_dir]
# add --gen erl if user options doesn't contain --gen
opts = opts ++ unless Enum.member?(user_options, "--gen"), do: ~w[--gen erl]
# merge user options
unless Enum.member?(user_options, "--gen") do
opts = opts ++ ~w[--gen erl]
end
opts ++ user_options
end

Expand Down

0 comments on commit 8d4943c

Please sign in to comment.