Kaynağa Gözat

Add support for manipulating empty json files

Jordi Boggiano 11 yıl önce
ebeveyn
işleme
534bd64cd1
1 değiştirilmiş dosya ile 3 ekleme ve 0 silme
  1. 3 0
      src/Composer/Json/JsonManipulator.php

+ 3 - 0
src/Composer/Json/JsonManipulator.php

@@ -34,6 +34,9 @@ class JsonManipulator
         }
 
         $contents = trim($contents);
+        if ($contents === '') {
+            $contents = '{}';
+        }
         if (!$this->pregMatch('#^\{(.*)\}$#s', $contents)) {
             throw new \InvalidArgumentException('The json file must be an object ({})');
         }