Sha256: eef0ec555698941a670691d20c43acaffe783cc676f91f03cb6d94c36f3bf52b

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

require_relative 'action'
require_relative '../helpers/system_commands'

module Arli
  module Actions
    class MoveToLibraryPath < Action

      description 'Moves the downloaded library to the proper path, optionally creating a backup'

      include ::Arli::Helpers::SystemCommands

      def execute
        Dir.chdir(config.runtime.pwd) do
          handle_preexisting_folder(path) if exists?
          if Dir.exist?(temp_path) && !Dir.exist?(path)
            FileUtils.mkdir_p(File.dirname(path))
            ___ "current: #{Dir.pwd.yellow}\ntemp_path: #{temp_path.yellow}\nlibrary_path: #{path.yellow}\n" if debug?
            if folder && Dir.exist?("#{temp_path}/#{folder}")
              mv("#{temp_path}/#{folder}", path)
              FileUtils.rm_rf(temp_path)
            else
              mv(temp_path, path)
            end
          elsif Dir.exist?(path)
            raise ::Arli::Errors::InstallerError,
                  "Directory #{path} was not expected to still be there!"
          elsif !Dir.exist?(temp_path)
            raise ::Arli::Errors::InstallerError,
                  "Directory #{temp_path} was expected to exist!"
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arli-1.4.0 lib/arli/actions/move_to_library_path.rb
arli-1.3.0 lib/arli/actions/move_to_library_path.rb