This repository was archived by the owner on Feb 13, 2023. It is now read-only.
File tree 2 files changed +8
-23
lines changed
2 files changed +8
-23
lines changed Original file line number Diff line number Diff line change 1
1
# -*- mode: ruby -*-
2
2
# vi: set ft=ruby :
3
3
4
- require_relative 'lib/drupalvm/vagrant'
5
-
6
4
drupalvm_env = ENV [ 'DRUPALVM_ENV' ] || 'vagrant'
7
5
8
6
# Default paths when the project is based on Drupal VM.
9
7
host_project_dir = host_drupalvm_dir = host_config_dir = __dir__
10
8
guest_project_dir = guest_drupalvm_dir = guest_config_dir = '/vagrant'
11
9
12
10
if File . exist? ( "#{ host_project_dir } /composer.json" )
13
- cconfig = load_composer_config ( "#{ host_project_dir } /composer.json" )
11
+ cconfig = { }
12
+ composer_conf = JSON . parse ( File . read ( "#{ host_project_dir } /composer.json" ) )
13
+ if composer_conf [ 'extra' ] && composer_conf [ 'extra' ] [ 'drupalvm' ]
14
+ cconfig = composer_conf [ 'extra' ] [ 'drupalvm' ]
15
+ end
14
16
15
17
# If Drupal VM is a Composer dependency set the correct path.
18
+ vendor_dir = composer_conf . fetch ( 'extra' , { } ) . fetch ( 'vendor-dir' , 'vendor' )
16
19
drupalvm_path = "#{ vendor_dir } /geerlingguy/drupal-vm"
17
20
if Dir . exist? ( "#{ host_project_dir } /#{ drupalvm_path } " )
18
21
host_drupalvm_dir = "#{ host_project_dir } /#{ drupalvm_path } "
@@ -26,6 +29,8 @@ if File.exist?("#{host_project_dir}/composer.json")
26
29
end
27
30
end
28
31
32
+ require "#{ host_drupalvm_dir } /lib/drupalvm/vagrant"
33
+
29
34
default_config_file = "#{ host_drupalvm_dir } /default.config.yml"
30
35
unless File . exist? ( default_config_file )
31
36
raise_message "Configuration file not found! Expected in #{ default_config_file } "
Original file line number Diff line number Diff line change @@ -34,16 +34,6 @@ def resolve_jinja_variables(vconfig)
34
34
end
35
35
end
36
36
37
- # Return the drupalvm extra-field from the passed composer.json
38
- def load_composer_config ( path )
39
- cconfig = { }
40
- composer_conf = JSON . parse ( File . read ( path ) )
41
- if composer_conf [ 'extra' ] && composer_conf [ 'extra' ] [ 'drupalvm' ]
42
- cconfig = composer_conf [ 'extra' ] [ 'drupalvm' ]
43
- end
44
- cconfig
45
- end
46
-
47
37
# Return the combined configuration content all files provided.
48
38
def load_config ( files )
49
39
vconfig = { }
@@ -66,16 +56,6 @@ def ansible_version
66
56
/^[^\s ]+ (.+)$/ . match ( `#{ ansible_bin } --version` ) { |match | return match [ 1 ] }
67
57
end
68
58
69
- # Return the path to the composer executable
70
- def composer_bin
71
- @composer_bin ||= which ( 'composer' )
72
- end
73
-
74
- # Return Composer's vendor directory.
75
- def vendor_dir
76
- @vendor_dir ||= composer_bin ? `#{ composer_bin } config vendor-dir` . strip : 'vendor'
77
- end
78
-
79
59
# Require that if installed, the ansible version meets the requirements.
80
60
def require_ansible_version ( requirement )
81
61
return unless ansible_bin
You can’t perform that action at this time.
0 commit comments