Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.

Commit 7158dbd

Browse files
committed
Revert previous commit and fix the loading of Drupal VM ruby lib
1 parent 63122b3 commit 7158dbd

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

Vagrantfile

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- mode: ruby -*-
22
# vi: set ft=ruby :
33

4-
require './lib/drupalvm/vagrant'
4+
require 'json'
55

66
drupalvm_env = ENV['DRUPALVM_ENV'] || 'vagrant'
77

@@ -10,9 +10,14 @@ host_project_dir = host_drupalvm_dir = host_config_dir = __dir__
1010
guest_project_dir = guest_drupalvm_dir = guest_config_dir = '/vagrant'
1111

1212
if File.exist?("#{host_project_dir}/composer.json")
13-
cconfig = load_composer_config("#{host_project_dir}/composer.json")
13+
cconfig = {}
14+
composer_conf = JSON.parse(File.read("#{host_project_dir}/composer.json"))
15+
if composer_conf['extra'] && composer_conf['extra']['drupalvm']
16+
cconfig = composer_conf['extra']['drupalvm']
17+
end
1418

1519
# If Drupal VM is a Composer dependency set the correct path.
20+
vendor_dir = composer_conf.fetch('extra', {}).fetch('vendor-dir', 'vendor')
1621
drupalvm_path = "#{vendor_dir}/geerlingguy/drupal-vm"
1722
if Dir.exist?("#{host_project_dir}/#{drupalvm_path}")
1823
host_drupalvm_dir = "#{host_project_dir}/#{drupalvm_path}"
@@ -26,6 +31,8 @@ if File.exist?("#{host_project_dir}/composer.json")
2631
end
2732
end
2833

34+
require "#{host_drupalvm_dir}/lib/drupalvm/vagrant"
35+
2936
default_config_file = "#{host_drupalvm_dir}/default.config.yml"
3037
unless File.exist?(default_config_file)
3138
raise_message "Configuration file not found! Expected in #{default_config_file}"

lib/drupalvm/vagrant.rb

-20
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,6 @@ def resolve_jinja_variables(vconfig)
3434
end
3535
end
3636

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-
4737
# Return the combined configuration content all files provided.
4838
def load_config(files)
4939
vconfig = {}
@@ -66,16 +56,6 @@ def ansible_version
6656
/^[^\s]+ (.+)$/.match(`#{ansible_bin} --version`) { |match| return match[1] }
6757
end
6858

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-
7959
# Require that if installed, the ansible version meets the requirements.
8060
def require_ansible_version(requirement)
8161
return unless ansible_bin

0 commit comments

Comments
 (0)