@@ -137,7 +137,7 @@ public function installHooks(Event $event): void
137
137
$ this ->io ->write (' <comment>plugin is disabled</comment> ' );
138
138
return ;
139
139
}
140
-
140
+
141
141
if (getenv ('CI ' ) === 'true ' ) {
142
142
$ this ->io ->write (' <comment>disabling plugin due to CI-environment</comment> ' );
143
143
return ;
@@ -205,15 +205,20 @@ private function runCaptainCommand(string $command): void
205
205
// Respect composer CLI settings
206
206
$ ansi = $ this ->io ->isDecorated () ? ' --ansi ' : ' --no-ansi ' ;
207
207
$ interaction = $ this ->io ->isInteractive () ? '' : ' --no-interaction ' ;
208
+ $ executable = escapeshellarg ($ this ->executable );
208
209
209
210
// captainhook config and repository settings
210
211
$ 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
+ }
214
219
215
220
// sub process settings
216
- $ cmd = $ executable . ' ' . $ command . $ ansi . $ interaction . $ skip . $ configuration . $ repository ;
221
+ $ cmd = $ executable . ' ' . $ command . $ ansi . $ interaction . $ forceOrSkip . $ configuration . $ repository ;
217
222
$ pipes = [];
218
223
$ spec = [
219
224
0 => ['file ' , 'php://stdin ' , 'r ' ],
@@ -314,4 +319,15 @@ private function isPluginDisabled(): bool
314
319
$ extra = $ this ->composer ->getPackage ()->getExtra ();
315
320
return (bool ) ($ extra ['captainhook ' ]['disable-plugin ' ] ?? false );
316
321
}
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
+ }
317
333
}
0 commit comments