Commits

Anonymous committed 405d7a5

making build_rel more dynamic

Comments (0)

Files changed (1)

src/emongo_app.erl

    ]}}.
 
 build_rel() ->
+	Apps = [kernel,stdlib,sasl],
     {ok, FD} = file:open("emongo.rel", [write]),
     RelInfo = {release,
         {"emongo", "0.3"},
-        {erts, "5.7.2"}, [
-            {kernel, "2.13.2"},
-            {stdlib, "1.16.2"},
-            {sasl, "2.1.6"},
+        get_app_version(erts), 
+            [get_app_version(AppName) || AppName <- Apps] ++ [
             {emongo, "0.0.1"}
         ]
     },
     io:format(FD, "~p.", [RelInfo]),
     file:close(FD),
     systools:make_script("emongo", [local]),
-    ok.
+    ok.
+
+get_app_version(AppName) ->
+	case code:lib_dir(AppName) of
+		{error, bad_name} ->
+			exit({bad_name, AppName});
+		Dir ->
+			case lists:reverse(string:tokens(Dir, "-")) of
+				[Vsn|_] -> {AppName, Vsn};
+				_ ->
+					exit({failed_to_tokenize, Dir})
+			end
+	end.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.