Ensure that watcher does not try to run a module that is not a koan

This commit is contained in:
Uku Taht
2016-04-06 10:08:51 +01:00
parent 305b6f8ca5
commit 04817ff6e8
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