 defmodule Mix.Tasks.Archive.Install do
   use Mix.Task
-
-  import Mix.Generator, only: [create_file: 2]
 
   @shortdoc "Install an archive locally"
 


    if opts[:force] || should_install?(src, previous) do
      remove_previous_versions(previous)
      dest = Mix.Local.archives_path()
      File.mkdir_p!(dest)
      archive = Path.join(dest, basename(src))
      create_file archive, Mix.Utils.read_path!(src, opts)
      true = Code.append_path(Mix.Archive.ebin(archive))
    else
      false

                   "Are you sure you want to replace them?")
  end

  defp check_file_exists(path) do
    # OTP keeps loaded archives open, this leads to unfortunate behaviour on
    # Windows when trying overwrite loaded archives. remove_previous_versions
    # completes successfully even though the file will be first removed after
    # the BEAM process is dead. Because of this we ask the user rerun the
    # command, which should complete successfully at that time

    if File.exists?(path) and match?({:win32, _}, :os.type) do
      Mix.raise "Unable to overwrite open archives on Windows. Run the command again"
    end
  end

  defp previous_versions(src) do
    app = src
          |> Mix.Archive.dir
