diff --git a/lib/watcher.ex b/lib/watcher.ex index a183cad..6839b55 100644 --- a/lib/watcher.ex +++ b/lib/watcher.ex @@ -24,7 +24,7 @@ defmodule Watcher do if Path.extname(file) == ".ex" do try do file - |> Code.compile_file() + |> portable_load_file |> Enum.map(&elem(&1, 0)) |> Enum.find(&Runner.koan?/1) |> Runner.modules_to_run() @@ -35,6 +35,17 @@ defmodule Watcher do end end + # Elixir 1.7 deprecates Code.load_file in favor of Code.compile_file. In + # order to avoid the depecation warnings while maintaining backwards + # compatibility, we check the sytem version and execute conditionally. + defp portable_load_file(file) do + if Version.match?(System.version(), "~> 1.7") do + Code.compile_file(file) + else + Code.load_file(file) + end + end + defp normalize(file) do String.replace_suffix(file, "___jb_tmp___", "") end