forked from zepgram/magento2-fast-vm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dependency.rb
72 lines (59 loc) · 1.81 KB
/
dependency.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/ruby
# @Author: Dev_NIX
require 'getoptlong'
def check_plugins(dependencies)
skip_dependency_manager = false
ARGV.each_with_index do |value, index|
case value
when '--skip-dependency-manager'
skip_dependency_manager = true
end
end
if ['up', 'reload'].include?(ARGV[0]) && !skip_dependency_manager
installed_dependencies = []
puts "\033[0m" << "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("(").to_i-1)).strip
end
dependencies_already_satisfied = true
dependencies.each_with_index do |dependency, index|
if not installed_dependencies.include? dependency
dependencies_already_satisfied = false
puts "\033[0m" << " - Missing '#{dependency}'!" << "\e[0m"
if not system "vagrant plugin install #{dependency}"
puts "\n\033[0m" << " - Could not install plugin '#{dependency}'. " << "\e[0m\033[41m" <<"Stopped." << "\e[0m"
exit -1
end
end
end
if dependencies_already_satisfied
puts "\033[0m" << " - All dependencies already satisfied" << "\e[0m"
else
puts "\033[0m" << " - Dependencies installed" << "\e[0m"
exec "vagrant " << "--skip-dependency-manager " << ARGV.join(" ")
exit
end
end
if ARGV.include?('--skip-dependency-manager')
ARGV.delete_at(ARGV.index('--skip-dependency-manager'))
end
end
# Get OS
module OS
def OS.is_windows
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
end
def OS.is_mac
(/darwin/ =~ RUBY_PLATFORM) != nil
end
def OS.is_linux
!OS.is_windows and not OS.is_mac
end
end