Skip to content

Commit ce8ed0e

Browse files
committed
Installer now runs automatically on post-update-cmd if project is not installed, installation command renamed to 'runFromComposer'
1 parent f7ee386 commit ce8ed0e

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@
5050
],
5151
"scripts": {
5252
"post-create-project-cmd": [
53-
"ViewComponents\\TestingHelpers\\Installer\\Installer::postComposerInstall"
53+
"ViewComponents\\TestingHelpers\\Installer\\Installer::runFromComposer"
54+
],
55+
"post-update-cmd": [
56+
"ViewComponents\\TestingHelpers\\Installer\\Installer::runFromComposer"
5457
],
5558
"test": "php vendor/phpunit/phpunit/phpunit",
5659
"serve": "php serve",

src/Installer/AbstractInstaller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ abstract class AbstractInstaller
1414

1515
abstract public function run();
1616

17-
public static function postComposerInstall(Event $event)
17+
public static function runFromComposer(Event $event)
1818
{
1919
$installer = new static($event);
2020
$installer->run();

src/Installer/Installer.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<?php
22
namespace ViewComponents\TestingHelpers\Installer;
33

4-
use Composer\Script\Event;
5-
64
class Installer extends AbstractInstaller
75
{
86
public function run()
97
{
108
if ($this->isInstalled()) {
11-
if (false === $this->askYesNo('Application already installed. Reinstall?', false)) {
9+
if (
10+
$this->event->getName() === 'post-update-cmd'
11+
|| false === $this->askYesNo('Application already installed. Reinstall?', false)
12+
) {
1213
goto finish;
1314
};
1415
}

0 commit comments

Comments
 (0)