Access project version within elixir application

后端 未结 6 1128
挽巷
挽巷 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:44

    Application.spec(:my_app, :vsn) works when the application is started. If you're in a Mix task and you don't need to start the application, in Elixir 1.8 you can use:

    MyApp.MixProject.project |> Keyword.fetch!(:version)
    

提交回复
热议问题