Skip to content

Commit

Permalink
Use Keyword.get/3 to query project config values
Browse files Browse the repository at this point in the history
This has a nicer and more explicit default value syntax.
  • Loading branch information
jparise committed May 28, 2016
1 parent 054de82 commit f0bd731
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/mix/tasks/compile.thrift.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,16 @@ defmodule Mix.Tasks.Compile.Thrift do
@spec run(OptionParser.argv) :: :ok | :noop
def run(args) do
{opts, _, _} = OptionParser.parse(args, switches: [force: :boolean])
force = opts[:force]

project = Mix.Project.config
thrift_files = project[:thrift_files] || []
thrift_executable = project[:thrift_executable] || "thrift"
thrift_options = project[:thrift_options] || []
thrift_version = project[:thrift_version]
output_dir = project[:thrift_output] || "src"
config = Mix.Project.config
thrift_files = Keyword.get(config, :thrift_files, [])
thrift_executable = Keyword.get(config, :thrift_executable, "thrift")
thrift_options = Keyword.get(config, :thrift_options, [])
thrift_version = Keyword.get(config, :thrift_version)
output_dir = Keyword.get(config, :thrift_output, "src")

stale_files = Enum.filter(thrift_files, fn file ->
force || stale?(file, output_dir)
opts[:force] || stale?(file, output_dir)
end)

unless(System.find_executable(thrift_executable)) do
Expand Down

0 comments on commit f0bd731

Please sign in to comment.