diff options
author | Lev Walkin <vlm@lionet.info> | 2012-08-06 22:12:01 +0400 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2012-08-08 00:52:54 +0200 |
commit | f2f294d8120f00423e20f47d364f515a47cba7ba (patch) | |
tree | 6304b9c9fba2a81355cbb598f3b71402c78c84a3 /src | |
parent | ca8d7cc95d0fa4da6b2801e14d24f62c139732ba (diff) |
Do not rewrite .app file if it didn't change
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_file_utils.erl | 14 | ||||
-rw-r--r-- | src/rebar_otp_app.erl | 2 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl index a3d9b58..fcd9c5e 100644 --- a/src/rebar_file_utils.erl +++ b/src/rebar_file_utils.erl @@ -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"). @@ -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 %% =================================================================== diff --git a/src/rebar_otp_app.erl b/src/rebar_otp_app.erl index 62befa1..a62f584 100644 --- a/src/rebar_otp_app.erl +++ b/src/rebar_otp_app.erl @@ -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 |