lib/berkshelf/vagrant.rb in vagrant-berkshelf-2.0.1 vs lib/berkshelf/vagrant.rb in vagrant-berkshelf-3.0.0.rc1

- old
+ new

@@ -2,20 +2,34 @@ require 'vagrant' rescue LoadError raise 'The Vagrant Berkshelf plugin must be run within Vagrant.' end -require 'berkshelf' require 'fileutils' require 'json' require 'tmpdir' require_relative 'vagrant/errors' require_relative 'vagrant/version' module Berkshelf + class << self + # Returns the filepath to the location Berkshelf will use for + # storage; temp files will go here, Cookbooks will be downloaded + # to or uploaded from here. By default this is '~/.berkshelf' but + # can be overridden by specifying a value for the ENV variable + # 'BERKSHELF_PATH'. + # + # @return [String] + def berkshelf_path + ENV['BERKSHELF_PATH'] || File.expand_path('~/.berkshelf') + end + end + module Vagrant + require_relative 'vagrant/chef_config' + require_relative 'vagrant/berks_config' require_relative 'vagrant/action' require_relative 'vagrant/config' require_relative 'vagrant/env' require_relative 'vagrant/env_helpers' @@ -33,10 +47,9 @@ # Generate a new shelf to be mounted in a Vagrant guest # # @return [String] # path to the generated shelf def mkshelf(machine_name = nil) - unless File.exist?(shelf_path) FileUtils.mkdir_p(shelf_path) end if machine_name.nil?