Skip to content

Commit

Permalink
Fix install step at the end of init command
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Apr 20, 2021
1 parent 9ed241c commit 2a50a94
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Composer/Command/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$question = 'Would you like to install dependencies now [<comment>yes</comment>]? ';
if ($input->isInteractive() && $this->hasDependencies($options) && $io->askConfirmation($question)) {
$this->installDependencies($output);
$this->updateDependencies($output);
}

return 0;
Expand Down Expand Up @@ -837,13 +837,14 @@ private function findSimilar($package)
return array_keys(array_slice($similarPackages, 0, 5));
}

private function installDependencies($output)
private function updateDependencies($output)
{
try {
$installCommand = $this->getApplication()->find('install');
$installCommand->run(new ArrayInput(array()), $output);
$updateCommand = $this->getApplication()->find('update');
$this->getApplication()->resetComposer();
$updateCommand->run(new ArrayInput(array()), $output);
} catch (\Exception $e) {
$this->getIO()->writeError('Could not install dependencies. Run `composer install` to see more information.');
$this->getIO()->writeError('Could not update dependencies. Run `composer update` to see more information.');
}
}

Expand Down

0 comments on commit 2a50a94

Please sign in to comment.