Packages

Installs a docker development environment into your project.

Current section

Files

Jump to
dockerize_elixir lib dockerize_elixir path.ex
Raw

lib/dockerize_elixir/path.ex

defmodule DockerizeElixir.Path do
# For some reason Path.relative_to/2 doesn't actually do anything if the given path is absolute
def relative_to(path, from) do
[relative_path, relative_from] = remove_same_prefix(Path.split(path), Path.split(from))
relative_from
|> Enum.map(fn _ -> ".." end)
|> Enum.concat(relative_path)
|> Path.join()
end
defp remove_same_prefix([head | tail1], [head | tail2]) do
remove_same_prefix(tail1, tail2)
end
defp remove_same_prefix(list1, list2), do: [list1, list2]
end