                     "File: #{file}\n  " <>
                     "Reason: #{reason}"
               end
-            end)
-        end
+          end
+        end)
     end
   end
 

    end
  end
  defp copy_app(app_dir, target_dir, false, include_src?) do
    case include_src? do
      true ->
        case File.cp_r(app_dir, target_dir) do
          {:ok, _} -> :ok
          {:error, reason, file} ->
            raise "unable to copy app directory:\n  " <>
              "#{app_dir} -> #{target_dir}\n  " <>
              "File: #{file}\n  " <>
              "Reason: #{reason}"
        end
      false ->
        case File.mkdir_p(target_dir) do
          {:error, reason} ->
            raise "unable to create app directory:\n  " <>
              "#{target_dir}\n  " <>
              "Reason: #{reason}"
          :ok ->
            Path.wildcard(Path.join(app_dir, "*"))
            |> Enum.filter(fn p -> Path.basename(p) in ["ebin", "include", "priv", "lib", "src"] end)
            |> Enum.each(fn p ->
              t = Path.join(target_dir, Path.basename(p))
              case File.cp_r(p, t) do
                {:ok, _} -> :ok
                {:error, reason, file} ->

      true ->
        File.rm_rf!(path)
      false ->
        if symlink?(path) do
          File.rm!(path)
        end
    end
    :ok
  end

  defp symlink?(path) do
    case :file.read_link_info('#{path}') do
      {:ok, info} ->
        elem(info, 2) == :symlink
      _ ->
        false
    end
  end

  # Creates release metadata files
