generate_app
author Simon MacMullen <simon@rabbitmq.com>
Fri Feb 03 15:59:12 2012 +0000 (3 months ago)
changeset 8922 4f87837a40be
parent 7221 66aea6682a84
permissions -rw-r--r--
Merge bug24702
     1 #!/usr/bin/env escript
     2 %% -*- erlang -*-
     3 
     4 main([InFile, OutFile | SrcDirs]) ->
     5     Modules = [list_to_atom(filename:basename(F, ".erl")) ||
     6                   SrcDir <- SrcDirs,
     7                   F <- filelib:wildcard("*.erl", SrcDir)],
     8     {ok, [{application, Application, Properties}]} = file:consult(InFile),
     9     NewProperties =
    10         case proplists:get_value(modules, Properties) of
    11             [] -> lists:keyreplace(modules, 1, Properties, {modules, Modules});
    12             _  -> Properties
    13         end,
    14     file:write_file(
    15       OutFile,
    16       io_lib:format("~p.~n", [{application, Application, NewProperties}])).