Skip to content

Commit

Permalink
Hotfix for Install and Remove commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Shevchuk committed Jul 19, 2021
1 parent 9298aae commit 7dc613b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/Command/Module/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
namespace Bluzman\Command\Module;

use Bluzman\Command\AbstractCommand;
use Composer\Console\Application as ComposerApplication;
use Exception;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -52,8 +53,9 @@ protected function configure()
* @param InputInterface $input
* @param OutputInterface $output
* @return int
* @throws Exception
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
// Composer\Factory::getHomeDir() method
// needs COMPOSER_HOME environment variable set
Expand All @@ -66,10 +68,8 @@ protected function execute(InputInterface $input, OutputInterface $output)

// call `composer install` command programmatically
$composerInput = new ArrayInput($arguments);
$application = new ComposerApplication();
$application = new Application();
$application->setAutoExit(false); // prevent `$application->run` method from exiting the script
$application->run($composerInput);

return 0;
return $application->run($composerInput);
}
}
11 changes: 6 additions & 5 deletions src/Command/Module/RemoveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
namespace Bluzman\Command\Module;

use Bluzman\Command\AbstractCommand;
use Composer\Console\Application as ComposerApplication;
use Exception;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -52,8 +53,9 @@ protected function configure()
* @param InputInterface $input
* @param OutputInterface $output
* @return int
* @throws Exception
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
// Composer\Factory::getHomeDir() method
// needs COMPOSER_HOME environment variable set
Expand All @@ -66,9 +68,8 @@ protected function execute(InputInterface $input, OutputInterface $output)

// call `composer install` command programmatically
$composerInput = new ArrayInput($arguments);
$application = new ComposerApplication();
$application = new Application();
$application->setAutoExit(false); // prevent `$application->run` method from exiting the script
$application->run($composerInput);
return 0;
return $application->run($composerInput);
}
}

0 comments on commit 7dc613b

Please sign in to comment.