Skip to content

Commit f059366

Browse files
committed
This plugin now tries to provide functionality only on 'vagrant up' and 'vagrant reload' commands
1 parent e26420a commit f059366

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

dependency_manager.rb

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,47 @@
55
# @Last Modified time: 2016-03-07 16:36:38
66

77
def check_plugins(dependencies)
8-
installed_dependencies = []
8+
if ['up', 'reload'].include? ARGV[0]
9+
installed_dependencies = []
910

10-
puts "\033[1m" << "Checking dependencies..." << "\e[0m"
11+
puts "\033[1m" << "Checking dependencies..." << "\e[0m"
1112

12-
raw_output = `vagrant plugin list`
13-
raw_list = raw_output.split("\n")
13+
raw_output = `vagrant plugin list`
14+
raw_list = raw_output.split("\n")
1415

15-
raw_list.each do |plugin|
16-
if plugin.index("\e[0m") != nil
17-
first = plugin.index("\e[0m") + 4
18-
else
19-
first = 0
16+
raw_list.each do |plugin|
17+
if plugin.index("\e[0m") != nil
18+
first = plugin.index("\e[0m") + 4
19+
else
20+
first = 0
21+
end
22+
installed_dependencies.push plugin.slice((first)..(plugin.index("(")-1)).strip
2023
end
21-
installed_dependencies.push plugin.slice((first)..(plugin.index("(")-1)).strip
22-
end
2324

24-
no_missing = false
25-
26-
dependencies.each_with_index do |dependency, index|
27-
if not installed_dependencies.include? dependency
28-
puts "\033[33m" << " - Missing '#{dependency}'!" << "\e[0m"
29-
if not system "vagrant plugin install #{dependency}"
30-
puts "\n\033[33m" << " - Could not install plugin '#{dependency}'. " << "\e[0m\033[41m" <<"Stopped." << "\e[0m"
31-
exit -1
25+
no_missing = false
26+
27+
dependencies.each_with_index do |dependency, index|
28+
if not installed_dependencies.include? dependency
29+
puts "\033[33m" << " - Missing '#{dependency}'!" << "\e[0m"
30+
if not system "vagrant plugin install #{dependency}"
31+
puts "\n\033[33m" << " - Could not install plugin '#{dependency}'. " << "\e[0m\033[41m" <<"Stopped." << "\e[0m"
32+
exit -1
33+
end
34+
35+
if no_missing == nil
36+
no_missing = false
37+
end
38+
else
39+
if no_missing == nil
40+
no_missing = true
41+
end
3242
end
43+
end
3344
34-
if no_missing == nil
35-
no_missing = false
36-
end
45+
if no_missing
46+
puts "\033[1m\033[36m" << " - All dependencies already satisfied" << "\e[0m"
3747
else
38-
if no_missing == nil
39-
no_missing = true
40-
end
48+
puts "\033[1m\033[32m" << " - Dependencies installed" << "\e[0m"
4149
end
4250
end
43-
44-
if no_missing
45-
puts "\033[1m\033[36m" << " - All dependencies already satisfied" << "\e[0m"
46-
else
47-
puts "\033[1m\033[32m" << " - Dependencies installed" << "\e[0m"
48-
end
49-
5051
end

0 commit comments

Comments
 (0)