This repository was archived by the owner on Feb 13, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -57,9 +57,35 @@ public function addVagrantfile(Event $event) {
5757
5858 if (file_exists ($ source )) {
5959 if (!file_exists ($ target ) || md5_file ($ source ) != md5_file ($ target )) {
60+ $ isLegacy = $ this ->isLegacyVagrantfile ($ target );
61+
6062 copy ($ source , $ target );
63+
64+ $ extra = $ this ->composer ->getPackage ()->getExtra ();
65+ if ($ isLegacy && !isset ($ extra ['drupalvm ' ]['config_dir ' ])) {
66+ $ this ->io ->writeError (
67+ '<warning> '
68+ . 'Drupal VM has been updated and consequently written over your Vagrantfile which from now on will be managed by Drupal VM. '
69+ . 'Due to this change, you are required to set the `config_dir` location in your composer.json file: '
70+ . "\n"
71+ . "\n $ composer config extra.drupalvm.config_dir <sub-directory> "
72+ . "\n"
73+ . '</warning> '
74+ );
75+ }
6176 }
6277 }
6378 }
6479
80+ /**
81+ * Return if the parent project is using the < 5.0.0 delegating Vagrantfile.
82+ *
83+ * @return bool
84+ */
85+ private function isLegacyVagrantfile ($ vagrantfile ) {
86+ if (!file_exists ($ vagrantfile )) {
87+ return false ;
88+ }
89+ return strpos (file_get_contents ($ vagrantfile ), '# Load the real Vagrantfile ' ) !== false ;
90+ }
6591}
You can’t perform that action at this time.
0 commit comments