Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
851B

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.OTPVersion do
  5. @spec version() :: String.t() | nil
  6. def version do
  7. # OTP Version https://erlang.org/doc/system_principles/versions.html#otp-version
  8. [
  9. Path.join(:code.root_dir(), "OTP_VERSION"),
  10. Path.join([:code.root_dir(), "releases", :erlang.system_info(:otp_release), "OTP_VERSION"])
  11. ]
  12. |> get_version_from_files()
  13. end
  14. @spec get_version_from_files([Path.t()]) :: String.t() | nil
  15. def get_version_from_files([]), do: nil
  16. def get_version_from_files([path | paths]) do
  17. if File.exists?(path) do
  18. path
  19. |> File.read!()
  20. |> String.replace(~r/\r|\n|\s/, "")
  21. else
  22. get_version_from_files(paths)
  23. end
  24. end
  25. end