Skip to content

Commit

Permalink
Make sure that composer file exists before running (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
Isinlor authored and theofidry committed Jul 16, 2018
1 parent f4d9625 commit 8a386cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/BinCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('<info>Run with <comment>' . $input->__toString() . '</comment></info>', true, IOInterface::VERBOSE);
Expand Down
11 changes: 5 additions & 6 deletions tests/Fixtures/MyTestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 8a386cf

Please sign in to comment.