Sha256: 6db0fd3ac604d35a0a2e7efd900150df57c10cef29ec36d06738b1c9b2b99212

Contents?: true

Size: 727 Bytes

Versions: 4

Compression:

Stored size: 727 Bytes

Contents

module Berkshelf
  module Vagrant
    module Action
      # @author Jamie Winsor <reset@riotgames.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[:berkshelf].shelf = nil
          end

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

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
vagrant-berkshelf-1.2.0 lib/berkshelf/vagrant/action/clean.rb
berkshelf-vagrant-1.1.2 lib/berkshelf/vagrant/action/clean.rb
berkshelf-vagrant-1.1.0 lib/berkshelf/vagrant/action/clean.rb
berkshelf-vagrant-1.0.6 lib/berkshelf/vagrant/action/clean.rb