Merge pull request #59 from ukutaht/filter-koans-in-watcher

Ensure that watcher does not try to run a module that is not a koan
This commit is contained in:
Felipe Seré
2016-04-06 11:40:22 +01:00
2 changed files with 8 additions and 2 deletions

View File

@@ -14,6 +14,10 @@ defmodule Runner do
Tasks,
]
def koan?(module) do
Enum.member?(@modules, module)
end
def run do
Options.initial_koan
|>run

View File

@@ -4,8 +4,10 @@ defmodule Watcher do
def callback(file, events) do
if Enum.member?(events, :modified) do
try do
[{mod, _} | _] = Code.load_file(file)
Runner.run(mod)
Code.load_file(file)
|> Enum.map(&(elem(&1, 0)))
|> Enum.find(&Runner.koan?/1)
|> Runner.run
rescue
e -> Display.show_compile_error(e)
end