vagrant/plugins/commands/plugin/action/plugin_exists_check.rb
Chris Roberts ea25996b21
Update Vagrant behavior outside of installers
Remove customized require behaviors and modify the bin executable
to check for missing tools that Vagrant expects to exist when
running outside of an installer.
2025-04-02 11:40:17 -07:00

28 lines
720 B
Ruby

# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
require "vagrant/plugin/manager"
module VagrantPlugins
module CommandPlugin
module Action
# This class checks to see if the plugin is installed already, and
# if so, raises an exception/error to output to the user.
class PluginExistsCheck
def initialize(app, env)
@app = app
end
def call(env)
installed = Vagrant::Plugin::Manager.instance.installed_plugins
if !installed.key?(env[:plugin_name])
raise Vagrant::Errors::PluginNotInstalled,
name: env[:plugin_name]
end
@app.call(env)
end
end
end
end
end