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