Sha256: 42842cd37725e8e160f95d2232478af0e9e6428a3b900c22a74092a2c5e00a29

Contents?: true

Size: 734 Bytes

Versions: 8

Compression:

Stored size: 734 Bytes

Contents

module Berkshelf
  module Vagrant
    module Action
      # @author Jamie Winsor <jamie@vialstudios.com>
      class Clean
        include Berkshelf::Vagrant::EnvHelpers

        def initialize(app, env)
          @app = app
        end

        def call(env)
          if env[:berkshelf].shelf && File.exist?(env[:berkshelf].shelf)
            env[:berkshelf].ui.info "Cleaning Vagrant's berkshelf"

            FileUtils.remove_dir(env[:berkshelf].shelf, force: true)
            FileUtils.rm_f(cache_file(env))
            env[:berkshelf].shelf = nil
          end

          @app.call(env)
        rescue Berkshelf::BerkshelfError => e
          raise Berkshelf::VagrantWrapperError.new(e)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vagrant-berkshelf-2.0.0.rc2 lib/berkshelf/vagrant/action/clean.rb
vagrant-berkshelf-2.0.0.rc1 lib/berkshelf/vagrant/action/clean.rb
vagrant-berkshelf-1.3.7 lib/berkshelf/vagrant/action/clean.rb
vagrant-berkshelf-1.3.6 lib/berkshelf/vagrant/action/clean.rb
vagrant-berkshelf-1.3.5 lib/berkshelf/vagrant/action/clean.rb
vagrant-berkshelf-1.4.0.dev1 lib/berkshelf/vagrant/action/clean.rb
vagrant-berkshelf-1.3.4 lib/berkshelf/vagrant/action/clean.rb
vagrant-berkshelf-1.3.3 lib/berkshelf/vagrant/action/clean.rb