Access project version within elixir application

后端 未结 6 2110
故里飘歌
故里飘歌 2021-02-12 07:52

I have an elixir project with a defined version. How can I access this from within the running application.

in mix.exs

  def project do
    [app: :my_app         


        
6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-12 08:28

    Here's a similar approach to retrieve the version string. It also relies on the :application module, but is maybe a bit more straightforward:

    {:ok, vsn} = :application.get_key(:my_app, :vsn)
    List.to_string(vsn)
    

提交回复
热议问题