core: Silence ruby warnings when loading external machines
This commit is contained in:
parent
a0e9f46251
commit
4349800374
|
@ -1,6 +1,7 @@
|
||||||
require 'log4r'
|
require 'log4r'
|
||||||
|
|
||||||
require "vagrant/util/safe_puts"
|
require "vagrant/util/safe_puts"
|
||||||
|
require "vagrant/util/silence_warnings"
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module Plugin
|
module Plugin
|
||||||
|
@ -130,12 +131,18 @@ module Vagrant
|
||||||
@env.machine_index.release(entry)
|
@env.machine_index.release(entry)
|
||||||
|
|
||||||
# Create an environment for this location and yield the
|
# Create an environment for this location and yield the
|
||||||
# machine in that environment.
|
# machine in that environment. We silence warnings here because
|
||||||
env = Vagrant::Environment.new(
|
# Vagrantfiles often have constants, so people would otherwise
|
||||||
cwd: entry.vagrantfile_path,
|
# constantly (heh) get "already initialized constant" warnings.
|
||||||
home_path: @env.home_path,
|
machine = Vagrant::Util::SilenceWarnings.silence! do
|
||||||
)
|
env = Vagrant::Environment.new(
|
||||||
next env.machine(entry.name.to_sym, entry.provider.to_sym)
|
cwd: entry.vagrantfile_path,
|
||||||
|
home_path: @env.home_path,
|
||||||
|
)
|
||||||
|
env.machine(entry.name.to_sym, entry.provider.to_sym)
|
||||||
|
end
|
||||||
|
|
||||||
|
next machine
|
||||||
end
|
end
|
||||||
|
|
||||||
active_machines.each do |active_name, active_provider|
|
active_machines.each do |active_name, active_provider|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
module Vagrant
|
||||||
|
module Util
|
||||||
|
module SilenceWarnings
|
||||||
|
# This silences any Ruby warnings.
|
||||||
|
def self.silence!
|
||||||
|
original = $VERBOSE
|
||||||
|
$VERBOSE = nil
|
||||||
|
return yield
|
||||||
|
ensure
|
||||||
|
$VERBOSE = original
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue