Skip to content

Commit adb2c50

Browse files
committed
Attempt to download binary library with post-install script
1 parent 0968047 commit adb2c50

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/HtmlShot/Composer/Installer.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,27 @@
88

99
class Installer
1010
{
11+
private const PACKAGE_NAME = 'avvertix/html-shot';
12+
1113
public static function downloadArtifact(Event $event): void
1214
{
1315
$composer = $event->getComposer();
1416
$io = $event->getIO();
1517

16-
$extra = $composer->getPackage()->getExtra();
18+
// Look up this package in the local repository so we read its own
19+
// composer.json rather than the root project's composer.json.
20+
$localRepo = $composer->getRepositoryManager()->getLocalRepository();
21+
$package = $localRepo->findPackage(self::PACKAGE_NAME, '*');
22+
23+
if ($package !== null) {
24+
$packageRoot = $composer->getInstallationManager()->getInstallPath($package);
25+
$extra = $package->getExtra();
26+
} else {
27+
// Package is the root (development mode).
28+
$packageRoot = dirname(__DIR__, 3);
29+
$extra = $composer->getPackage()->getExtra();
30+
}
31+
1732
$artifacts = $extra['artifacts'] ?? [];
1833

1934
if ($artifacts === []) {
@@ -38,7 +53,6 @@ public static function downloadArtifact(Event $event): void
3853
return;
3954
}
4055

41-
$packageRoot = dirname(__DIR__, 3);
4256
$libDir = $packageRoot.'/lib';
4357

4458
if (! is_dir($libDir) && ! mkdir($libDir, 0755, true)) {

0 commit comments

Comments
 (0)