File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -76,17 +76,31 @@ public static function findEventListeners(Event $event): void
7676 return ;
7777 }
7878
79- if (array_key_exists ('name ' , $ json ) && $ json ['name ' ] === 'wyrihaximus/test-utilities ' ) {
80- self ::addMakeOnInstallOrUpdate ($ event ->getIO (), $ rootPackagePath );
79+ if (! array_key_exists ('require-dev ' , $ json )) {
80+ return ;
81+ }
8182
83+ if (! is_array ($ json ['require-dev ' ])) {
8284 return ;
8385 }
8486
85- if (! array_key_exists ('require-dev ' , $ json )) {
87+ $ hasMakefiles = false ;
88+ foreach (array_keys ($ json ['require-dev ' ]) as $ package ) {
89+ if ($ package === 'wyrihaximus/makefiles ' ) {
90+ $ hasMakefiles = true ;
91+ break ;
92+ }
93+ }
94+
95+ if (! $ hasMakefiles ) {
8696 return ;
8797 }
8898
89- if (! is_array ($ json ['require-dev ' ])) {
99+ unset($ hasMakefiles );
100+
101+ if (array_key_exists ('name ' , $ json ) && $ json ['name ' ] === 'wyrihaximus/test-utilities ' ) {
102+ self ::addMakeOnInstallOrUpdate ($ event ->getIO (), $ rootPackagePath );
103+
90104 return ;
91105 }
92106
@@ -150,7 +164,7 @@ private static function addMakeOnInstallOrUpdate(IOInterface $io, string $rootPa
150164 $ replacementComposerJsonString = preg_replace ('/^( +?) \\1(?=[^ ])/m ' , '$1 ' , $ replacementComposerJsonString );
151165 if (is_string ($ replacementComposerJsonString )) {
152166 $ io ->write ('<info>wyrihaximus/test-utilities:</info> Writing new <fg=cyan>composer.json</> ' );
153- file_put_contents ($ rootPackagePath . '/composer.json ' , $ replacementComposerJsonString );
167+ file_put_contents ($ rootPackagePath . '/composer.json ' , $ replacementComposerJsonString . "\r\n" );
154168 }
155169 }
156170 }
You can’t perform that action at this time.
0 commit comments