Skip to content

Commit 1767d02

Browse files
committed
586: allow --force param to always re-install a package
1 parent 59b2154 commit 1767d02

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

features/install-extensions.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,15 @@ Feature: Extensions can be installed with PIE
99
Example: An extension can be installed and enabled
1010
When I run a command to install an extension
1111
Then the extension should have been installed and enabled
12+
13+
# pie install <ext> && pie install <ext>
14+
Example: Re-installing an existing extension is a no-op
15+
Given an extension was previously installed and enabled
16+
When I run a command to install an extension
17+
Then the extension should not have been re-installed
18+
19+
# pie install <ext> && pie install --force <ext>
20+
Example: Forcefully re-installing an existing extension should re-install the extension
21+
Given an extension was previously installed and enabled
22+
When I run a command to forcefully install an extension
23+
Then the extension should have been installed and enabled

src/ComposerIntegration/ComposerIntegrationHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function runInstall(
8989
$status->description(),
9090
), verbosity: IOInterface::VERY_VERBOSE);
9191

92-
if ($status->isVerified()) {
92+
if ($status->isVerified() && ! $forceInstallPackageVersion) {
9393
$this->arrayCollectionIo->write(sprintf(
9494
'%s PIE package %s (%s) is already installed and verified.',
9595
Emoji::GREEN_CHECKMARK,

test/behaviour/CliContext.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ public function iRunACommandToInstallAnExtension(): void
191191
$this->runPieCommand(['install', $this->thePackage]);
192192
}
193193

194+
#[When('I run a command to forcefully install an extension')]
195+
public function iRunACommandToForcefullyInstallAnExtension(): void
196+
{
197+
$this->theExtension = 'example_pie_extension';
198+
$this->thePackage = 'asgrim/example-pie-extension';
199+
$this->runPieCommand(['install', '--force', $this->thePackage]);
200+
}
201+
194202
#[When('I run a command to install an extension without enabling it')]
195203
public function iRunACommandToInstallAnExtensionWithoutEnabling(): void
196204
{
@@ -265,6 +273,20 @@ public function theExtensionShouldHaveBeenInstalledAndEnabled(): void
265273
Assert::same($isExtEnabled, 'yes');
266274
}
267275

276+
#[Then('the extension should not have been re-installed')]
277+
public function theExtensionShouldNotHaveBeenReinstalled(): void
278+
{
279+
$this->assertCommandSuccessful();
280+
281+
Assert::contains($this->output, 'PIE package asgrim/example-pie-extension (example_pie_extension) is already installed and verified.');
282+
283+
$isExtEnabled = (new Process([self::PHP_BINARY, '-r', 'echo extension_loaded("' . $this->theExtension . '")?"yes":"no";']))
284+
->mustRun()
285+
->getOutput();
286+
287+
Assert::same($isExtEnabled, 'yes');
288+
}
289+
268290
#[Given('I have an invalid extension installed')]
269291
public function iHaveAnInvalidExtensionInstalled(): void
270292
{

0 commit comments

Comments
 (0)