如何从Vagrantfile中检测插件是否已安装?

29

我希望检测插件是否已安装,以便为用户添加一些有用的调试提示。

我尝试了以下代码:

  if config.vbguest
    config.vbguest.auto_update = true
  else
    puts "installing vagrant-vbguest plugin is recommended"
  end

然而,Vagrant输出* Unknown configuration section 'vbguest'.

我能否检测插件是否已安装?

1个回答

48

Vagrant.has_plugin?(name) 方法会返回一个布尔值,如果某个插件已经被安装,则为 true。

示例:

unless Vagrant.has_plugin?("vagrant-some-plugin")
  raise 'some-plugin is not installed!'
end

原始来源:stackoverflow答案


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接