Access project version within elixir application

后端 未结 6 1106
挽巷
挽巷 2021-02-12 07:42

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:46

    In recent versions of Elixir, the Application module now wraps this for you:

    https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/application.ex

    Application.spec(:my_app, :vsn) |> to_string()

    The Kernel.to_string() method is necessary as Application.spec/2 for the keys :vsn and :description return charlists. to_string() from the Kernel module converts them to a binary.

提交回复
热议问题