diff --git a/lib/dialyxir/project.ex b/lib/dialyxir/project.ex index ba60a708..3a3251cd 100644 --- a/lib/dialyxir/project.ex +++ b/lib/dialyxir/project.ex @@ -1,12 +1,15 @@ defmodule Dialyxir.Project do @moduledoc false - def plts_list(deps) do + def plts_list(deps, include_project \\ true) do elixir_apps = [:elixir] erlang_apps = [:erts, :kernel, :stdlib, :crypto] - [{plt_file(), deps ++ elixir_apps ++ erlang_apps}, - {elixir_plt(), elixir_apps}, - {erlang_plt(), erlang_apps}] + core_plts = [ {elixir_plt(), elixir_apps}, {erlang_plt(), erlang_apps}] + if include_project do + [{plt_file(), deps ++ elixir_apps ++ erlang_apps} | core_plts] + else + core_plts + end end def plt_file() do diff --git a/lib/mix/tasks/dialyzer.ex b/lib/mix/tasks/dialyzer.ex index c9ad72f5..2d47f7bb 100644 --- a/lib/mix/tasks/dialyzer.ex +++ b/lib/mix/tasks/dialyzer.ex @@ -4,6 +4,8 @@ defmodule Mix.Tasks.Dialyzer do @moduledoc """ This task compiles the mix project, creates a PLT with dependencies if needed and runs `dialyzer`. Much of its behavior can be managed in configuration as described below. + If executed outside of a mix project, it will build the core PLT files and exit. + ## Command line options * `--no-compile` - do not compile even if needed. @@ -80,20 +82,25 @@ defmodule Mix.Tasks.Dialyzer do def run(args) do check_dialyzer() compatibility_notice() - Project.check_config() - {dargs, compile} = Enum.partition(args, &(&1 != "--no-compile")) - {dargs, halt} = Enum.partition(dargs, &(&1 != "--halt-exit-status")) - {dargs, no_check} = Enum.partition(dargs, &(&1 != "--no-check")) - no_check = if in_child? do - IO.puts "In an Umbrella child, not checking PLT..." - ["--no-check"] - else - no_check - end - if compile == [], do: Mix.Project.compile([]) - unless no_check != [], do: check_plt() - args = List.flatten [dargs, "--no_check_plt", "--plt", "#{Project.plt_file()}", dialyzer_flags(), Project.dialyzer_paths()] - dialyze(args, halt) + if Mix.Project.get() do + Project.check_config() + {dargs, compile} = Enum.partition(args, &(&1 != "--no-compile")) + {dargs, halt} = Enum.partition(dargs, &(&1 != "--halt-exit-status")) + {dargs, no_check} = Enum.partition(dargs, &(&1 != "--no-check")) + no_check = if in_child? do + IO.puts "In an Umbrella child, not checking PLT..." + ["--no-check"] + else + no_check + end + if compile == [], do: Mix.Project.compile([]) + unless no_check != [], do: check_plt() + args = List.flatten [dargs, "--no_check_plt", "--plt", "#{Project.plt_file()}", dialyzer_flags(), Project.dialyzer_paths()] + dialyze(args, halt) + else + IO.puts "No mix project found - checking core PLTs..." + Project.plts_list([], false) |> Plt.check() + end end defp check_plt() do diff --git a/mix.exs b/mix.exs index 36d6e66c..30d1f64e 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Dialyxir.Mixfile do def project do [ app: :dialyxir, - version: "0.4.0", + version: "0.4.1", elixir: "> 1.3.2", description: description(), package: package(),