|
5 | 5 | # @Last Modified time: 2016-03-07 16:36:38
|
6 | 6 |
|
7 | 7 | def check_plugins(dependencies)
|
8 |
| - installed_dependencies = [] |
| 8 | + if ['up', 'reload'].include? ARGV[0] |
| 9 | + installed_dependencies = [] |
9 | 10 |
|
10 |
| - puts "\033[1m" << "Checking dependencies..." << "\e[0m" |
| 11 | + puts "\033[1m" << "Checking dependencies..." << "\e[0m" |
11 | 12 |
|
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") |
14 | 15 |
|
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 |
20 | 23 | end
|
21 |
| - installed_dependencies.push plugin.slice((first)..(plugin.index("(")-1)).strip |
22 |
| - end |
23 | 24 |
|
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 |
32 | 42 | end
|
| 43 | + end |
33 | 44 |
|
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" |
37 | 47 | else
|
38 |
| - if no_missing == nil |
39 |
| - no_missing = true |
40 |
| - end |
| 48 | + puts "\033[1m\033[32m" << " - Dependencies installed" << "\e[0m" |
41 | 49 | end
|
42 | 50 | 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 |
| -
|
50 | 51 | end
|
0 commit comments