2020-03-03 02:19:29 -07:00
|
|
|
# Pleroma: A lightweight social networking server
|
2023-01-02 13:38:50 -07:00
|
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
2020-03-03 02:19:29 -07:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
2020-02-11 00:12:57 -07:00
|
|
|
|
2020-03-03 02:19:29 -07:00
|
|
|
defmodule Pleroma.OTPVersion do
|
2020-03-03 23:23:42 -07:00
|
|
|
@spec version() :: String.t() | nil
|
|
|
|
def version do
|
2020-02-11 00:12:57 -07:00
|
|
|
# OTP Version https://erlang.org/doc/system_principles/versions.html#otp-version
|
2020-03-03 02:19:29 -07:00
|
|
|
[
|
2020-02-11 00:12:57 -07:00
|
|
|
Path.join(:code.root_dir(), "OTP_VERSION"),
|
|
|
|
Path.join([:code.root_dir(), "releases", :erlang.system_info(:otp_release), "OTP_VERSION"])
|
|
|
|
]
|
2020-03-03 02:19:29 -07:00
|
|
|
|> get_version_from_files()
|
2020-02-11 00:12:57 -07:00
|
|
|
end
|
|
|
|
|
2020-03-03 23:23:42 -07:00
|
|
|
@spec get_version_from_files([Path.t()]) :: String.t() | nil
|
|
|
|
def get_version_from_files([]), do: nil
|
2020-02-11 00:12:57 -07:00
|
|
|
|
2020-03-03 23:23:42 -07:00
|
|
|
def get_version_from_files([path | paths]) do
|
2020-02-11 00:12:57 -07:00
|
|
|
if File.exists?(path) do
|
2020-03-03 23:23:42 -07:00
|
|
|
path
|
|
|
|
|> File.read!()
|
|
|
|
|> String.replace(~r/\r|\n|\s/, "")
|
2020-02-11 00:12:57 -07:00
|
|
|
else
|
2020-03-03 02:19:29 -07:00
|
|
|
get_version_from_files(paths)
|
2020-02-11 00:12:57 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|