Kaynağa Gözat

Only create the root file empty and error out on missing local files

Jordi Boggiano 12 yıl önce
ebeveyn
işleme
a4e5f000d5
1 değiştirilmiş dosya ile 8 ekleme ve 6 silme
  1. 8 6
      src/Composer/Command/ConfigCommand.php

+ 8 - 6
src/Composer/Command/ConfigCommand.php

@@ -99,13 +99,15 @@ EOT
             : $input->getOption('file');
 
         $this->configFile = new JsonFile($this->configFile);
-        if (!$this->configFile->exists()) {
+
+        // initialize the global file if it's not there
+        if ($input->getOption('global') && !$this->configFile->exists()) {
             touch($this->configFile->getPath());
-            // If you read an empty file, Composer throws an error
-            // Toss some of the defaults in there
-            $defaults = Config::$defaultConfig;
-            $defaults['repositories'] = Config::$defaultRepositories;
-            $this->configFile->write($defaults);
+            $this->configFile->write(array('config' => new \ArrayObject));
+        }
+
+        if (!$this->configFile->exists()) {
+            throw new \RuntimeException('No composer.json found in the current directory');
         }
     }