1
0
Fork 0

RequireCommand - rollback if it fails (fixes #1469)

pull/1552/head
Bilal Amarni 2013-02-01 10:24:05 +01:00
parent 3b2accfb58
commit 99e4173b3d
1 changed files with 7 additions and 1 deletions

View File

@ -69,6 +69,7 @@ EOT
$json = new JsonFile($file);
$composer = $json->read();
$composerBackup = file_get_contents($json->getPath());
$requirements = $this->determineRequirements($input, $output, $input->getArgument('packages'));
@ -106,7 +107,12 @@ EOT
->setUpdateWhitelist($requirements);
;
return $install->run() ? 0 : 1;
if (!$install->run()) {
$output->writeln("\n".'<error>Installation failed, reverting '.$file.' to its original content.</error>');
file_put_contents($json->getPath(), $composerBackup);
return 1;
}
}
private function updateFileCleanly($json, array $base, array $new, $requireKey)