Skip to content

Commit

Permalink
Do not rewrite .app file if it didn't change
Browse files Browse the repository at this point in the history
  • Loading branch information
vlm authored and Tuncer Ayaz committed Aug 7, 2012
1 parent ca8d7cc commit f2f294d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/rebar_file_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
-export([rm_rf/1,
cp_r/2,
mv/2,
delete_each/1]).
delete_each/1,
write_file_if_contents_differ/2]).

-include("rebar.hrl").

Expand Down Expand Up @@ -111,6 +112,17 @@ delete_each([File | Rest]) ->
?FAIL
end.

write_file_if_contents_differ(Filename, Bytes) ->
ToWrite = iolist_to_binary(Bytes),
case file:read_file(Filename) of
{ok, ToWrite} ->
ok;
{ok, _} ->
file:write_file(Filename, ToWrite);
{error, _} ->
file:write_file(Filename, ToWrite)
end.

%% ===================================================================
%% Internal functions
%% ===================================================================
Expand Down
2 changes: 1 addition & 1 deletion src/rebar_otp_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ preprocess(Config, AppSrcFile) ->

%% Setup file .app filename and write new contents
AppFile = rebar_app_utils:app_src_to_app(AppSrcFile),
ok = file:write_file(AppFile, Spec),
ok = rebar_file_utils:write_file_if_contents_differ(AppFile, Spec),

%% Make certain that the ebin/ directory is available
%% on the code path
Expand Down

0 comments on commit f2f294d

Please sign in to comment.