-
Notifications
You must be signed in to change notification settings - Fork 0
/
dependency_manager.rb
executable file
·51 lines (43 loc) · 1.33 KB
/
dependency_manager.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/ruby
# @Author: Dev_NIX
# @Date: 2016-03-07 14:24:11
# @Last Modified by: Dev_NIX
# @Last Modified time: 2016-03-07 16:36:38
def check_plugins(dependencies)
if ['up', 'reload'].include? ARGV[0]
installed_dependencies = []
puts "\033[1m" << "Checking dependencies..." << "\e[0m"
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
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
end
if no_missing == nil
no_missing = false
end
else
if no_missing == nil
no_missing = true
end
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
end