Преглед на файлове

Initialize config if it does not exist yet

Jordi Boggiano преди 12 години
родител
ревизия
cf0753e062
променени са 1 файла, в които са добавени 5 реда и са изтрити 1 реда
  1. 5 1
      src/Composer/Config/JsonConfigSource.php

+ 5 - 1
src/Composer/Config/JsonConfigSource.php

@@ -63,7 +63,11 @@ class JsonConfigSource implements ConfigSourceInterface
         array_shift($args);
         $fallback = array_pop($args);
 
-        $contents = file_get_contents($this->file->getPath());
+        if ($this->file->exists()) {
+            $contents = file_get_contents($this->file->getPath());
+        } else {
+            $contents = "{\n    \"config\": {\n    }\n}\n";
+        }
         $manipulator = new JsonManipulator($contents);
 
         // try to update cleanly