mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 07:50:24 +08:00
fix: allow path repos
Temporarily configure cwd while running composer commands so that path repositories can be resolved properly. Fixes https://github.com/flarum/package-manager/issues/6
This commit is contained in:
parent
a7535ab20a
commit
919ba129f4
@ -10,6 +10,7 @@
|
||||
namespace Flarum\PackageManager\Composer;
|
||||
|
||||
use Composer\Console\Application;
|
||||
use Flarum\Foundation\Paths;
|
||||
use Flarum\PackageManager\OutputLogger;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
@ -34,10 +35,16 @@ class ComposerAdapter
|
||||
*/
|
||||
private $output;
|
||||
|
||||
public function __construct(Application $application, OutputLogger $logger)
|
||||
/**
|
||||
* @var Paths
|
||||
*/
|
||||
private $paths;
|
||||
|
||||
public function __construct(Application $application, OutputLogger $logger, Paths $paths)
|
||||
{
|
||||
$this->application = $application;
|
||||
$this->logger = $logger;
|
||||
$this->paths = $paths;
|
||||
$this->output = new BufferedOutput();
|
||||
}
|
||||
|
||||
@ -45,7 +52,11 @@ class ComposerAdapter
|
||||
{
|
||||
$this->application->resetComposer();
|
||||
|
||||
// This hack is necessary so that relative path repositories are resolved properly.
|
||||
$currDir = getcwd();
|
||||
chdir($this->paths->base);
|
||||
$exitCode = $this->application->run($input, $this->output);
|
||||
chdir($currDir);
|
||||
|
||||
$outputContents = $this->output->fetch();
|
||||
|
||||
|
@ -50,7 +50,7 @@ class PackageManagerServiceProvider extends AbstractServiceProvider
|
||||
@ini_set('memory_limit', '1G');
|
||||
@set_time_limit(5 * 60);
|
||||
|
||||
return new ComposerAdapter($composer, $container->make(OutputLogger::class));
|
||||
return new ComposerAdapter($composer, $container->make(OutputLogger::class), $container->make(Paths::class));
|
||||
});
|
||||
|
||||
$this->container->alias(ComposerAdapter::class, 'flarum.composer');
|
||||
|
Loading…
x
Reference in New Issue
Block a user