@@ -125,14 +125,22 @@ private static function addMakeOnInstallOrUpdate(IOInterface $io, string $rootPa
125125
126126 $ composerJson = json_decode ($ composerJsonString , true );
127127 $ composerJsonHash = hash ('sha512 ' , (string ) json_encode ($ composerJson , JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ));
128- if (is_array ($ composerJson ) && array_key_exists ( ' scripts ' , $ composerJson ) && is_array ( $ composerJson [ ' scripts ' ]) ) {
129- if (array_key_exists ('post-install-cmd ' , $ composerJson ['scripts ' ])) {
130- $ composerJson ['scripts ' ][ ' post-install-cmd ' ] = self :: addMakeOnInstallOrUpdateToScriptsSectionAndRemoveCommandsItReplaces ( $ composerJson [ ' scripts ' ][ ' post-install-cmd ' ]) ;
128+ if (is_array ($ composerJson )) {
129+ if (! ( array_key_exists ('scripts ' , $ composerJson) && is_array ( $ composerJson ['scripts ' ]) )) {
130+ $ composerJson ['scripts ' ] = [] ;
131131 }
132132
133- if (array_key_exists ('post-update -cmd ' , $ composerJson ['scripts ' ])) {
134- $ composerJson ['scripts ' ]['post-update -cmd ' ] = self :: addMakeOnInstallOrUpdateToScriptsSectionAndRemoveCommandsItReplaces ( $ composerJson [ ' scripts ' ][ ' post-update-cmd ' ]) ;
133+ if (! array_key_exists ('post-install -cmd ' , $ composerJson ['scripts ' ])) {
134+ $ composerJson ['scripts ' ]['post-install -cmd ' ] = [] ;
135135 }
136+
137+ $ composerJson ['scripts ' ]['post-install-cmd ' ] = self ::addMakeOnInstallOrUpdateToScriptsSectionAndRemoveCommandsItReplaces ($ composerJson ['scripts ' ]['post-install-cmd ' ]);
138+
139+ if (! array_key_exists ('post-update-cmd ' , $ composerJson ['scripts ' ])) {
140+ $ composerJson ['scripts ' ]['post-update-cmd ' ] = [];
141+ }
142+
143+ $ composerJson ['scripts ' ]['post-update-cmd ' ] = self ::addMakeOnInstallOrUpdateToScriptsSectionAndRemoveCommandsItReplaces ($ composerJson ['scripts ' ]['post-update-cmd ' ]);
136144 }
137145
138146 $ replacementComposerJsonString = json_encode ($ composerJson , JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT );
0 commit comments