     end
   end
 
-  defp checked_deps(build, deps) do
-    for root <- [deps, build],
+  defp checked_deps(build_path, deps_path) do
+    for root <- [deps_path, build_path],
         path <- Path.wildcard(Path.join(root, "*")),
         File.dir?(path) do
       Path.basename(path)

    |> List.delete(to_string(Mix.Project.config[:app]))
  end

  defp filter_loaded(apps, opts) do
    load_opts = if only = opts[:only], do: [env: :"#{only}"], else: []
    load_deps = Mix.Dep.loaded(load_opts) |> Enum.map(&Atom.to_string(&1.app))
    Enum.reject(apps, &(&1 in load_deps))
  end

  defp do_clean(apps, build, deps, build_only?) do
    shell = Mix.shell
    loaded_deps = Mix.Dep.loaded([])

    Enum.each apps, fn(app) ->
      shell.info "* Cleaning #{app}"

      # Remove everything from the build directory of dependencies
      build
      |> Path.join(to_string(app))
      |> Path.wildcard
      |> Enum.each(&File.rm_rf!/1)

                  "the --unused option cleans unused dependencies"
    end

    do_clean(apps_to_clean, loaded_deps, build_path, deps_path, opts[:build])

    if opts[:unlock] do
      Mix.Task.run "deps.unlock", args
