diff --git a/lib/mix/tasks/compiler.ex b/lib/mix/tasks/compiler.ex index 4be5725..6a8733f 100644 --- a/lib/mix/tasks/compiler.ex +++ b/lib/mix/tasks/compiler.ex @@ -14,26 +14,38 @@ defmodule Mix.Tasks.Compile.Speck do hashes = hashes(files) manifest = load_manifest() + # files_to_clean = + # Enum.map(manifest, fn {_hash, file} -> file end) -- files + + # IO.inspect files_to_clean, label: "files_to_clean" + modified_files = hashes |> Enum.reject(&Enum.member?(manifest, &1)) |> Enum.map(fn {_hash, file} -> file end) - Enum.each(modified_files, fn file -> + Enum.each(modified_files, fn {hash, file, _module} -> Mix.Shell.IO.info "Compiling #{file}" - compile(file) - |> Enum.each(fn {module, bytecode} -> + file + |> compile() + |> Enum.map(fn {module, bytecode} -> path = Path.join([Mix.Project.app_path, "ebin", "#{module}.beam"]) File.mkdir_p(Path.dirname(path)) File.write(path, bytecode) + + {hash, file, module} end) end) + # -------------------------------------------------------------------------- + # TODO: Clean removed & renamed files + # -------------------------------------------------------------------------- + files |> hashes() - |> save_manifest() + |> save_manifest() :ok end