build 734 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env escript
  2. main(_) ->
  3. Files = lists:ukeysort(1, lists:flatten(files())),
  4. {ok, {"mad", ZipBin}} = zip:create("mad", Files, [memory]),
  5. Script = iolist_to_binary([
  6. "#!/usr/bin/env escript\n",
  7. "%% " ++ comment(),
  8. "%%! -pa mad/mad/ebin\n",
  9. ZipBin]),
  10. file:write_file("mad", Script),
  11. os:cmd("chmod +x mad").
  12. files() ->
  13. [read_file(F) || F <- filelib:wildcard("*", "ebin")].
  14. read_file(F) ->
  15. [[{"ebin/", <<>>}], {F, file_contents(F)}].
  16. file_contents(F) ->
  17. {ok, Bin} = file:read_file(filename:join("ebin", F)),
  18. Bin.
  19. comment() ->
  20. "Dependency manager for Erlang\n".