From cf0753e06283d10cfc56da3ed312c4f6fa10c3b7 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 18 Oct 2012 18:18:40 +0200 Subject: [PATCH] Initialize config if it does not exist yet --- src/Composer/Config/JsonConfigSource.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Composer/Config/JsonConfigSource.php b/src/Composer/Config/JsonConfigSource.php index 8de10a51e..384e153c8 100644 --- a/src/Composer/Config/JsonConfigSource.php +++ b/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