Explorar o código

Fix parser error if composer.json existing but empty

vlakoff %!s(int64=10) %!d(string=hai) anos
pai
achega
3a68534d20
Modificáronse 1 ficheiros con 4 adicións e 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 (file_get_contents($file) === '') {
+            file_put_contents($file, "{\n}\n");
+        }
+
         $json = new JsonFile($file);
         $composerDefinition = $json->read();
         $composerBackup = file_get_contents($json->getPath());