Skip to content

Commit

Permalink
use version as argument for getInstallCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
chr-hertel committed Mar 8, 2024
1 parent 3a389da commit 020a71d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/Entity/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,16 +687,14 @@ public function getType(): string|null
return $this->type;
}

public function getInstallCommand(): string
public function getInstallCommand(Version $version = null): string
{
$command = 'create-project';

if ('project' !== $this->getType()) {
$command = 'require';

/** @var Version $version */
$version = $this->getVersions()->first();
if ($version && $version->hasDevTag()) {
if (null !== $version && $version->hasDevTag()) {
$command .= ' --dev';
}
}
Expand Down
2 changes: 1 addition & 1 deletion templates/package/view_package.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

<div class="row">
<div class="col-md-8">
<p class="requireme"><i class="glyphicon glyphicon-save"></i> <input type="text" readonly="readonly" value="{{ package.installCommand }}" /></p>
<p class="requireme"><i class="glyphicon glyphicon-save"></i> <input type="text" readonly="readonly" value="{{ package.installCommand(expandedVersion) }}" /></p>

{% if not package.isAutoUpdated() and is_granted('update', package) %}
{% if "github.com" in package.repository %}
Expand Down
3 changes: 1 addition & 2 deletions tests/Entity/PackageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ public function testInstallCommand(string $type, string $tag, string $expected):
$package = new Package();
$package->setName('vendor/name');
$package->setType($type);
$package->addVersion($version);

self::assertSame($expected, $package->getInstallCommand());
self::assertSame($expected, $package->getInstallCommand($version));
}

public static function providePackageScenarios(): array
Expand Down

0 comments on commit 020a71d

Please sign in to comment.