utils.ex (597B)
1 defmodule ExSync.Utils do 2 def recomplete do 3 System.cmd("mix", ["compile"], cd: ExSync.Config.app_source_dir()) 4 end 5 6 def unload(module) when is_atom(module) do 7 module |> :code.purge() 8 module |> :code.delete() 9 end 10 11 def unload(beam_path) do 12 beam_path |> Path.basename(".beam") |> String.to_atom() |> unload 13 end 14 15 # beam file path 16 def reload(beam_path) do 17 file = beam_path |> to_charlist 18 {:ok, binary, _} = :erl_prim_loader.get_file(file) 19 module = beam_path |> Path.basename(".beam") |> String.to_atom() 20 :code.load_binary(module, file, binary) 21 end 22 end