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 +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -57,9 +57,34 @@ 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 your `config_dir` location in your composer.json file. Below follows the necessary change: '
70+ . '</warning> '
71+ );
72+ $ this ->io ->writeError ('' );
73+ $ this ->io ->writeError (json_encode (['extra ' => ['drupalvm ' => ['config_dir ' => '<sub-directory> ' ]]], JSON_PRETTY_PRINT ));
74+ }
6175 }
6276 }
6377 }
6478
79+ /**
80+ * Return if the parent project is using the < 5.0.0 delegating Vagrantfile.
81+ *
82+ * @return bool
83+ */
84+ private function isLegacyVagrantfile ($ vagrantfile ) {
85+ if (!file_exists ($ vagrantfile )) {
86+ return false ;
87+ }
88+ return strpos (file_get_contents ($ vagrantfile ), '# Load the real Vagrantfile ' ) !== FALSE ;
89+ }
6590}
You can’t perform that action at this time.
0 commit comments