@@ -137,7 +137,7 @@ public function installHooks(Event $event): void
137137 $ this ->io ->write (' <comment>plugin is disabled</comment> ' );
138138 return ;
139139 }
140-
140+
141141 if (getenv ('CI ' ) === 'true ' ) {
142142 $ this ->io ->write (' <comment>disabling plugin due to CI-environment</comment> ' );
143143 return ;
@@ -205,15 +205,20 @@ private function runCaptainCommand(string $command): void
205205 // Respect composer CLI settings
206206 $ ansi = $ this ->io ->isDecorated () ? ' --ansi ' : ' --no-ansi ' ;
207207 $ interaction = $ this ->io ->isInteractive () ? '' : ' --no-interaction ' ;
208+ $ executable = escapeshellarg ($ this ->executable );
208209
209210 // captainhook config and repository settings
210211 $ configuration = ' -c ' . escapeshellarg ($ this ->configuration );
211- $ repository = $ command === self ::COMMAND_INSTALL ? ' -g ' . escapeshellarg ($ this ->gitDirectory ) : '' ;
212- $ skip = $ command === self ::COMMAND_INSTALL ? ' -s ' : '' ;
213- $ executable = escapeshellarg ($ this ->executable );
212+ $ repository = '' ;
213+ $ forceOrSkip = '' ;
214+
215+ if ($ command === self ::COMMAND_INSTALL ) {
216+ $ repository = ' -g ' . escapeshellarg ($ this ->gitDirectory );
217+ $ forceOrSkip = $ this ->isForceInstall () ? ' -f ' : ' -s ' ;
218+ }
214219
215220 // sub process settings
216- $ cmd = $ executable . ' ' . $ command . $ ansi . $ interaction . $ skip . $ configuration . $ repository ;
221+ $ cmd = $ executable . ' ' . $ command . $ ansi . $ interaction . $ forceOrSkip . $ configuration . $ repository ;
217222 $ pipes = [];
218223 $ spec = [
219224 0 => ['file ' , 'php://stdin ' , 'r ' ],
@@ -314,4 +319,15 @@ private function isPluginDisabled(): bool
314319 $ extra = $ this ->composer ->getPackage ()->getExtra ();
315320 return (bool ) ($ extra ['captainhook ' ]['disable-plugin ' ] ?? false );
316321 }
322+
323+ /**
324+ * Is a force installation configured
325+ *
326+ * @return bool
327+ */
328+ private function isForceInstall (): bool
329+ {
330+ $ extra = $ this ->composer ->getPackage ()->getExtra ();
331+ return (bool ) ($ extra ['captainhook ' ]['force-install ' ] ?? false );
332+ }
317333}
0 commit comments