diff --git a/lib/vagrant/shared_helpers.rb b/lib/vagrant/shared_helpers.rb index d980e9723..a49871395 100644 --- a/lib/vagrant/shared_helpers.rb +++ b/lib/vagrant/shared_helpers.rb @@ -8,6 +8,15 @@ module Vagrant # @return [String] DEFAULT_SERVER_URL = "https://www.vagrantcloud.com" + # Returns the path to the embedded directory of the Vagrant installer, + # if there is one (if we're running in an installer). + # + # @return [String] + def self.installer_embedded_dir + return nil if !Vagrant.in_installer? + ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"] + end + # This returns whether or not 3rd party plugins should be loaded. # # @return [Boolean] diff --git a/test/unit/vagrant/shared_helpers_test.rb b/test/unit/vagrant/shared_helpers_test.rb index a604314e0..e4bd86b4f 100644 --- a/test/unit/vagrant/shared_helpers_test.rb +++ b/test/unit/vagrant/shared_helpers_test.rb @@ -8,6 +8,21 @@ describe Vagrant do subject { described_class } + describe "#installer_embedded_dir" do + it "returns nil if not in an installer" do + Vagrant.stub(in_installer?: false) + expect(subject.installer_embedded_dir).to be_nil + end + + it "returns the set directory" do + Vagrant.stub(in_installer?: true) + + with_temp_env("VAGRANT_INSTALLER_EMBEDDED_DIR" => "/foo") do + expect(subject.installer_embedded_dir).to eq("/foo") + end + end + end + describe "#plugins_enabled?" do it "returns true if the env is not set" do with_temp_env("VAGRANT_NO_PLUGINS" => nil) do