<commit_before>defmodule Mix.Tasks.Release.Clean do
  @moduledoc """
  Clean up any release-related files.

  ## Examples

    mix release.clean       #=> Cleans release
    mix release.clean --rel #=> Cleans release + generated tools
    mix release.clean --all #=> Cleans absolutely everything

  """
  @shortdoc "Clean up any release-related files."

  use     Mix.Task
  import  ExRM.Release.Utils

  @_RELXCONF "relx.config"
  @_RUNNER   "runner"

  def run(args) do
    debug "Removing release files..."
    cond do
      "--rel" in args ->
        do_cleanup :rel
      "--all" in args ->
        do_cleanup :all
      true ->
        do_cleanup :build
    end
    info "All release files were removed successfully!"
  end

  # Clean release build
  defp do_cleanup(:build) do
    cwd      = File.cwd!
    project  = Mix.project |> Keyword.get(:app) |> atom_to_binary
    release  = cwd |> Path.join("rel")    |> Path.join(project)
    build    = cwd |> Path.join("_build") |> Path.join("prod")
    if File.exists?(release), do: File.rm_rf!(release)
    if File.exists?(build) do
      build
      |> File.ls!
      |> Enum.map(fn dir -> build |> Path.join(dir) end)
      |> Enum.map(&IO.puts/1)
      #|> Enum.map(&File.rm_rf!/1)
    end
  end
  # Clean release build + generated tools
  defp do_cleanup(:rel) do
    # Execute build cleanup
    do_cleanup :build

    # Remove generated tools
    clean_relx
    relfiles = File.cwd! |> Path.join("rel")<commit_msg>Delete contents of _build/prod on clean<commit_after>defmodule Mix.Tasks.Release.Clean do
  @moduledoc """
  Clean up any release-related files.

  ## Examples

    mix release.clean       #=> Cleans release
    mix release.clean --rel #=> Cleans release + generated tools
    mix release.clean --all #=> Cleans absolutely everything

  """
  @shortdoc "Clean up any release-related files."

  use     Mix.Task
  import  ExRM.Release.Utils

  @_RELXCONF "relx.config"
  @_RUNNER   "runner"

  def run(args) do
    debug "Removing release files..."
    cond do
      "--rel" in args ->
        do_cleanup :rel
      "--all" in args ->
        do_cleanup :all
      true ->
        do_cleanup :build
    end
    info "All release files were removed successfully!"
  end

  # Clean release build
  defp do_cleanup(:build) do
    cwd      = File.cwd!
    project  = Mix.project |> Keyword.get(:app) |> atom_to_binary
    release  = cwd |> Path.join("rel")    |> Path.join(project)
    build    = cwd |> Path.join("_build") |> Path.join("prod")
    if File.exists?(release), do: File.rm_rf!(release)
    if File.exists?(build) do
      build
      |> File.ls!
      |> Enum.map(fn dir -> build |> Path.join(dir) end)
      |> Enum.map(&File.rm_rf!/1)
    end
  end
  # Clean release build + generated tools
  defp do_cleanup(:rel) do
    # Execute build cleanup
    do_cleanup :build

    # Remove generated tools
    clean_relx
    relfiles = File.cwd! |> Path.join("rel")
{'fraction_non_alphanumeric': 0.12444746684801088, 'fraction_numerical': 0.0010200612036722204, 'mean_word_length': 2.4693396226415096, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1053531', 'n_tokens_mistral': 975, 'n_tokens_neox': 949, 'n_words': 263}