1
0
Fork 0

Fixed the registration of commands with invalid JSON file

When the JSON file in the current folder is invalid, the registration of custom commands should be ignored rather than breaking the usage of Composer entirely.
Closes #3165
pull/3238/head
Christophe Coevoet 2014-08-25 21:52:36 +02:00
parent 1e27ff5e22
commit e1a3df3dbf
1 changed files with 1 additions and 2 deletions

View File

@ -113,8 +113,7 @@ class Application extends BaseApplication
// add non-standard scripts as own commands
$file = Factory::getComposerFile();
$json = new JsonFile($file);
if ($json->exists() && is_readable($file) && ($composer = $json->read())) {
if (is_file($file) && is_readable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
if (isset($composer['scripts']) && is_array($composer['scripts'])) {
foreach ($composer['scripts'] as $script => $dummy) {
if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {