소스 검색

Fix parser error if composer.json existing but empty

vlakoff 10 년 전
부모
커밋
3a68534d20
1개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  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());