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
matthias@729
     1
#!/usr/bin/env escript
matthias@729
     2
%% -*- erlang -*-
matthias@729
     3
matthew@7327
     4
main([InFile, OutFile | SrcDirs]) ->
simon@7219
     5
    Modules = [list_to_atom(filename:basename(F, ".erl")) ||
simon@7221
     6
                  SrcDir <- SrcDirs,
simon@7219
     7
                  F <- filelib:wildcard("*.erl", SrcDir)],
matthew@7327
     8
    {ok, [{application, Application, Properties}]} = file:consult(InFile),
simon@7220
     9
    NewProperties =
simon@7220
    10
        case proplists:get_value(modules, Properties) of
simon@7220
    11
            [] -> lists:keyreplace(modules, 1, Properties, {modules, Modules});
simon@7220
    12
            _  -> Properties
simon@7220
    13
        end,
matthias@2190
    14
    file:write_file(
matthew@7327
    15
      OutFile,
matthias@2190
    16
      io_lib:format("~p.~n", [{application, Application, NewProperties}])).