Explorar el Código

Merge pull request #3845 from vlakoff/empty-composer.json

Avoid parser error if composer.json existing but empty
Jordi Boggiano hace 10 años
padre
commit
4aa431025b
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  1. 4 0
      src/Composer/Command/RequireCommand.php

+ 4 - 0
src/Composer/Command/RequireCommand.php

@@ -82,6 +82,10 @@ EOT
             return 1;
         }
 
+        if (filesize($file) === 0) {
+            file_put_contents($file, "{\n}\n");
+        }
+
         $json = new JsonFile($file);
         $composerDefinition = $json->read();
         $composerBackup = file_get_contents($json->getPath());