`vagrant box` no longer requires a Vagrantfile in the current directory.
This commit is contained in:
parent
499ec7d633
commit
6194421972
|
@ -128,7 +128,7 @@ error
|
|||
# which action to take and calls the respective action method
|
||||
# (see {box_add} and {box_remove})
|
||||
def box(argv)
|
||||
Env.load!
|
||||
Env.load!(:suppress_errors => true)
|
||||
|
||||
sub_commands = ["add", "remove"]
|
||||
|
||||
|
|
|
@ -14,13 +14,13 @@ module Vagrant
|
|||
def box; @@box; end
|
||||
def persisted_vm; @@persisted_vm; end
|
||||
def root_path; @@root_path; end
|
||||
def dotfile_path; File.join(root_path, Vagrant.config.vagrant.dotfile_name); end
|
||||
def dotfile_path;File.join(root_path, Vagrant.config.vagrant.dotfile_name); end
|
||||
def home_path; File.expand_path(Vagrant.config.vagrant.home); end
|
||||
def tmp_path; File.join(home_path, "tmp"); end
|
||||
def boxes_path; File.join(home_path, "boxes"); end
|
||||
|
||||
def load!
|
||||
load_root_path!
|
||||
def load!(opts={})
|
||||
load_root_path!(Pathname.new(Dir.pwd), opts)
|
||||
load_config!
|
||||
load_home_directory!
|
||||
load_box!
|
||||
|
@ -31,7 +31,7 @@ module Vagrant
|
|||
# Prepare load paths for config files
|
||||
load_paths = [File.join(PROJECT_ROOT, "config", "default.rb")]
|
||||
load_paths << File.join(box.directory, ROOTFILE_NAME) if box
|
||||
load_paths << File.join(root_path, ROOTFILE_NAME)
|
||||
load_paths << File.join(root_path, ROOTFILE_NAME) if root_path
|
||||
|
||||
# Then clear out the old data
|
||||
Config.reset!
|
||||
|
@ -69,6 +69,8 @@ module Vagrant
|
|||
end
|
||||
|
||||
def load_vm!
|
||||
return unless root_path
|
||||
|
||||
File.open(dotfile_path) do |f|
|
||||
@@persisted_vm = Vagrant::VM.find(f.read)
|
||||
end
|
||||
|
|
|
@ -194,7 +194,7 @@ class CommandsTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should "load the environment" do
|
||||
Vagrant::Env.expects(:load!).once
|
||||
Vagrant::Env.expects(:load!).with(:suppress_errors => true).once
|
||||
Vagrant::Commands.box(["add"])
|
||||
end
|
||||
|
||||
|
|
|
@ -78,6 +78,12 @@ class EnvTest < Test::Unit::TestCase
|
|||
Vagrant::Env.load_config!
|
||||
end
|
||||
|
||||
should "not load from the root path if nil" do
|
||||
Vagrant::Env.stubs(:root_path).returns(nil)
|
||||
File.expects(:exist?).with(File.join(@root_path, Vagrant::Env::ROOTFILE_NAME)).never
|
||||
Vagrant::Env.load_config!
|
||||
end
|
||||
|
||||
should "not load from the box directory if it is nil" do
|
||||
Vagrant::Env.expects(:box).once.returns(nil)
|
||||
Vagrant::Env.load_config!
|
||||
|
@ -115,7 +121,7 @@ class EnvTest < Test::Unit::TestCase
|
|||
test "load! should load the config and set the persisted_uid" do
|
||||
Vagrant::Env.expects(:load_config!).once
|
||||
Vagrant::Env.expects(:load_vm!).once
|
||||
Vagrant::Env.expects(:load_root_path!).once
|
||||
Vagrant::Env.expects(:load_root_path!).with(Pathname.new(Dir.pwd), {}).once
|
||||
Vagrant::Env.expects(:load_home_directory!).once
|
||||
Vagrant::Env.expects(:load_box!).once
|
||||
Vagrant::Env.load!
|
||||
|
@ -144,6 +150,12 @@ class EnvTest < Test::Unit::TestCase
|
|||
assert_equal 'foovm', Vagrant::Env.persisted_vm
|
||||
end
|
||||
|
||||
should "do nothing if the root path is nil" do
|
||||
File.expects(:open).never
|
||||
Vagrant::Env.stubs(:root_path).returns(nil)
|
||||
Vagrant::Env.load_vm!
|
||||
end
|
||||
|
||||
test "uuid should be nil if dotfile didn't exist" do
|
||||
File.expects(:open).raises(Errno::ENOENT)
|
||||
Vagrant::Env.load_vm!
|
||||
|
|
Loading…
Reference in New Issue