Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure that composer file exists before running #42

Merged
merged 3 commits into from
Jul 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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