Sha256: 79833abe0037df79cb43a3158b05e6f9048f977b9dac07b0204c6281b5033751

Contents?: true

Size: 1021 Bytes

Versions: 5

Compression:

Stored size: 1021 Bytes

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?
            mv(temp_path, path)
          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

5 entries across 5 versions & 1 rubygems

Version Path
arli-1.2.1 lib/arli/actions/move_to_library_path.rb
arli-1.1.0 lib/arli/actions/move_to_library_path.rb
arli-1.0.2 lib/arli/actions/move_to_library_path.rb
arli-1.0.1 lib/arli/actions/move_to_library_path.rb
arli-1.0.0 lib/arli/actions/move_to_library_path.rb