diff --git a/src/BinCommand.php b/src/BinCommand.php index 5a299b1..93acaf4 100644 --- a/src/BinCommand.php +++ b/src/BinCommand.php @@ -102,6 +102,12 @@ private function executeInNamespace(ComposerApplication $application, $namespace } $this->chdir($namespace); + + // some plugins require access to composer file e.g. Symfony Flex + if (!file_exists(Factory::getComposerFile())) { + file_put_contents(Factory::getComposerFile(), '{}'); + } + $input = new StringInput((string) $input . ' --working-dir=.'); $this->getIO()->writeError('Run with ' . $input->__toString() . '', true, IOInterface::VERBOSE); diff --git a/tests/Fixtures/MyTestCommand.php b/tests/Fixtures/MyTestCommand.php index ee8ffce..f2f6bc6 100644 --- a/tests/Fixtures/MyTestCommand.php +++ b/tests/Fixtures/MyTestCommand.php @@ -27,12 +27,11 @@ public function __construct(\PHPUnit_Framework_Assert $assert) public function execute(InputInterface $input, OutputInterface $output) { - // make sure the proxy command didn't instantiate Composer - $this->assert->assertNull($this->getComposer(false)); - $this->assert->assertNull($this->getApplication()->getComposer(false)); - - // put a dummy composer.json to be able to create Composer - file_put_contents(getcwd().'/composer.json', '{}'); + $this->assert->assertInstanceOf( + '\Composer\Composer', + $this->getComposer(), + "Some plugins may require access to composer file e.g. Symfony Flex" + ); $factory = Factory::create(new NullIO()); $config = $factory->getConfig();