summaryrefslogtreecommitdiff
path: root/src/rebar_utils.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_utils.erl')
-rw-r--r--src/rebar_utils.erl32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 92f40ec..d3717cc 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -24,9 +24,39 @@
%% -------------------------------------------------------------------
-module(rebar_utils).
--export([get_cwd/0]).
+-export([get_cwd/0,
+ get_os/0]).
+
+
+%% ====================================================================
+%% Public API
+%% ====================================================================
get_cwd() ->
{ok, Dir} = file:get_cwd(),
Dir.
+
+get_os() ->
+ Arch = erlang:system_info(system_architecture),
+ case match_first([{"linux", linux}, {"darwin", darwin}], Arch) of
+ nomatch ->
+ {unknown, Arch};
+ ArchAtom ->
+ ArchAtom
+ end.
+
+
+%% ====================================================================
+%% Internal functions
+%% ====================================================================
+
+match_first([], Val) ->
+ nomatch;
+match_first([{Regex, MatchValue} | Rest], Val) ->
+ case re:run(Val, Regex, [{capture, none}]) of
+ match ->
+ MatchValue;
+ nomatch ->
+ match_first(Rest, Val)
+ end.