Skip to content

Commit

Permalink
This plugin now tries to provide functionality only on 'vagrant up' a…
Browse files Browse the repository at this point in the history
…nd 'vagrant reload' commands
  • Loading branch information
devnix committed Mar 21, 2016
1 parent e26420a commit f059366
Showing 1 changed file with 33 additions and 32 deletions.
65 changes: 33 additions & 32 deletions dependency_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,47 @@
# @Last Modified time: 2016-03-07 16:36:38

def check_plugins(dependencies)
installed_dependencies = []
if ['up', 'reload'].include? ARGV[0]
installed_dependencies = []

puts "\033[1m" << "Checking dependencies..." << "\e[0m"
puts "\033[1m" << "Checking dependencies..." << "\e[0m"

raw_output = `vagrant plugin list`
raw_list = raw_output.split("\n")
raw_output = `vagrant plugin list`
raw_list = raw_output.split("\n")

raw_list.each do |plugin|
if plugin.index("\e[0m") != nil
first = plugin.index("\e[0m") + 4
else
first = 0
raw_list.each do |plugin|
if plugin.index("\e[0m") != nil
first = plugin.index("\e[0m") + 4
else
first = 0
end
installed_dependencies.push plugin.slice((first)..(plugin.index("(")-1)).strip
end
installed_dependencies.push plugin.slice((first)..(plugin.index("(")-1)).strip
end

no_missing = false

dependencies.each_with_index do |dependency, index|
if not installed_dependencies.include? dependency
puts "\033[33m" << " - Missing '#{dependency}'!" << "\e[0m"
if not system "vagrant plugin install #{dependency}"
puts "\n\033[33m" << " - Could not install plugin '#{dependency}'. " << "\e[0m\033[41m" <<"Stopped." << "\e[0m"
exit -1
no_missing = false

dependencies.each_with_index do |dependency, index|
if not installed_dependencies.include? dependency
puts "\033[33m" << " - Missing '#{dependency}'!" << "\e[0m"
if not system "vagrant plugin install #{dependency}"
puts "\n\033[33m" << " - Could not install plugin '#{dependency}'. " << "\e[0m\033[41m" <<"Stopped." << "\e[0m"
exit -1
end
if no_missing == nil
no_missing = false
end
else
if no_missing == nil
no_missing = true
end
end
end
if no_missing == nil
no_missing = false
end
if no_missing
puts "\033[1m\033[36m" << " - All dependencies already satisfied" << "\e[0m"
else
if no_missing == nil
no_missing = true
end
puts "\033[1m\033[32m" << " - Dependencies installed" << "\e[0m"
end
end
if no_missing
puts "\033[1m\033[36m" << " - All dependencies already satisfied" << "\e[0m"
else
puts "\033[1m\033[32m" << " - Dependencies installed" << "\e[0m"
end
end

0 comments on commit f059366

Please sign in to comment.