File: new_mochiweb.erl

package info (click to toggle)
rabbitmq-server 2.8.4-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 8,928 kB
  • sloc: erlang: 52,968; python: 2,846; xml: 1,987; sh: 816; makefile: 683; perl: 86; ruby: 63
file content (37 lines) | stat: -rwxr-xr-x 871 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env escript
%% -*- mode: erlang -*-
-export([main/1]).

%% External API

main([Name]) ->
    main([Name, "."]);
main([Name, Dest]) ->
    ensure(),
    DestDir = filename:absname(Dest),
    case code:which(mochiweb_skel) of
        non_existing ->
            io:format("mochiweb not compiled, running make~n"),
            os:cmd("(cd \"" ++ filename:dirname(escript:script_name())
                   ++ "/..\"; make)"),
            ensure(),
            code:rehash();
        _ ->
            ok
    end,
    ok = mochiweb_skel:skelcopy(DestDir, Name);
main(_) ->
    usage().

%% Internal API

ensure() ->
    code:add_patha(filename:join(filename:dirname(escript:script_name()),
                                 "../ebin")).

usage() ->
    io:format("usage: ~s name [destdir]~n",
              [filename:basename(escript:script_name())]),
    halt(1).