Skip to content

Commit

Permalink
Don't revert composer.json when "require" fails because of scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Sep 22, 2021
1 parent ffee8ca commit 2cb1d4b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Composer/Command/RequireCommand.php
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Composer\EventDispatcher\ScriptExecutionException;
use Composer\Factory;
use Composer\Installer;
use Composer\Json\JsonFile;
Expand Down Expand Up @@ -269,6 +270,8 @@ protected function execute(InputInterface $input, OutputInterface $output)

try {
return $this->doUpdate($input, $output, $io, $requirements, $requireKey, $removeKey);
} catch (ScriptExecutionException $e) {
throw $e;
} catch (\Exception $e) {
$this->revertComposerFile(false);
throw $e;
Expand Down

0 comments on commit 2cb1d4b

Please sign in to comment.