Explorar o código

Initialize config if it does not exist yet

Jordi Boggiano %!s(int64=12) %!d(string=hai) anos
pai
achega
cf0753e062
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  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