emqx_plugin_template.app.src.script 800 B

123456789101112131415161718192021222324
  1. %%-*- mode: erlang -*-
  2. %% .app.src.script
  3. RemoveLeadingV =
  4. fun(Tag) ->
  5. case re:run(Tag, "^[v|e]?[0-9]\.[0-9]\.([0-9]|(rc|beta|alpha)\.[0-9])", [{capture, none}]) of
  6. nomatch ->
  7. re:replace(Tag, "/", "-", [{return ,list}]);
  8. _ ->
  9. %% if it is a version number prefixed by 'v' or 'e', then remove it
  10. re:replace(Tag, "[v|e]", "", [{return ,list}])
  11. end
  12. end,
  13. case os:getenv("EMQX_DEPS_DEFAULT_VSN") of
  14. false -> CONFIG; % env var not defined
  15. [] -> CONFIG; % env var set to empty string
  16. Tag ->
  17. [begin
  18. AppConf0 = lists:keystore(vsn, 1, AppConf, {vsn, RemoveLeadingV(Tag)}),
  19. {application, App, AppConf0}
  20. end || Conf = {application, App, AppConf} <- CONFIG]
  21. end.