secret
Created

  • Download Gist
gistfile1.erl
Erlang
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
sort_releases(Root) ->
RelDir = filename:join([Root, "releases"]),
[ begin
RelFilename = filename:join([RelDir, Release]),
{ok, [{release, {Name, Version}, {erts, _}, _}]} = file:consult(RelFilename),
case filename:dirname(Release) =:= Version of
true ->
ignore;
false -> %% move
ok = filelib:ensure_dir(filename:join([RelDir, Version]) ++ "/"), %% make sure appropriate directory exists
RelFiles = filelib:wildcard(Name ++ ".*", filename:join([RelDir, filename:dirname(Release)])), %% release files
[ file:rename(filename:join([RelDir, filename:dirname(Release), RelFile]),
filename:join([RelDir, Version, RelFile])) || RelFile <- RelFiles ]
end
end || Release <- filelib:wildcard("*/*.rel", RelDir) ],
ok.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.