     case :file.consult(target) do
       {:ok, [{:application, _app, properties}]} ->
         properties[:modules] != mods
+
       _ ->
         false
     end
   end
 
   defp validate_app(app) when is_atom(app), do: :ok
+
   defp validate_app(app) do
     ensure_present(:app, app)
     Mix.raise("Expected :app to be an atom, got: #{inspect(app)}")

  defp ensure_present(name, nil) do
    Mix.raise("Please ensure mix.exs file has the #{inspect(name)} in the project definition")
  end
  defp ensure_present(_name, _val), do: :ok

  defp modules_from(beams) do
    Enum.map beams, &(&1 |> Path.basename |> Path.rootname(".beam") |> String.to_atom)
  end

  defp language_app(config) do

  def run(args) do
    {opts, _, _} = OptionParser.parse(args, switches: [force: :boolean])

    project = Mix.Project.get!()
    config = Mix.Project.config()

    app = Keyword.get(config, :app)
    version = Keyword.get(config, :version)

    validate_app(app)
    validate_version(version)

    path = Mix.Project.compile_path()
    mods = modules_from(Path.wildcard("#{path}/*.beam")) |> Enum.sort()

    target = Path.join(path, "#{app}.app")
    sources = Mix.Project.config_files()

    if opts[:force] || Mix.Utils.stale?(sources, [target]) || modules_changed?(mods, target) do
      best_guess = [
        description: to_charlist(config[:description] || app),
        modules: mods,
        registered: [],
        vsn: to_charlist(version)
      ]

      properties =
        if function_exported?(project, :application, 0) do
          project_application = project.application

          unless Keyword.keyword?(project_application) do
            Mix.raise(
              "Application configuration returned from application/0 should be a keyword list"
            )
          end

          Keyword.merge(best_guess, project_application)
        else
          best_guess
        end

      properties = ensure_correct_properties(properties, config)
      contents = :io_lib.format("~p.~n", [{:application, app, properties}])

      Mix.Project.ensure_structure()
      File.write!(target, IO.chardata_to_string(contents))
      Mix.shell().info("Generated #{app} app")
      :ok
    else
      :noop
