Skip to content

Instantly share code, notes, and snippets.

@colinbankier
Created November 28, 2017 12:34
Show Gist options
  • Select an option

  • Save colinbankier/5f5e5178424f749cf70e595520679920 to your computer and use it in GitHub Desktop.

Select an option

Save colinbankier/5f5e5178424f749cf70e595520679920 to your computer and use it in GitHub Desktop.
Elchemy Find Deps
defmodule Elchemy.LocalDeps do
def find!(dir), do: find!([], dir)
def find!(dirs, dir) do
files = dir |> File.ls!
if Enum.member?(files, "mix.exs") do
[dir | dirs]
else
files
|> Enum.map(&Path.join(dir, &1))
|> Enum.filter(&File.dir?/1)
|> Enum.reduce(dirs, &find!(&2, &1))
end
end
end
Elchemy.LocalDeps.find!("elm-deps")
|> Enum.map(fn path ->
repo = path |> Path.split |> Enum.at(-2) |> String.to_atom
{repo, path: path}
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment