Sfoglia il codice sorgente

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

Jordi Boggiano 12 anni fa
parent
commit
a4e5f000d5
1 ha cambiato i file con 8 aggiunte e 6 eliminazioni
  1. 8 6
      src/Composer/Command/ConfigCommand.php

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

@@ -99,13 +99,15 @@ EOT
             : $input->getOption('file');
             : $input->getOption('file');
 
 
         $this->configFile = new JsonFile($this->configFile);
         $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());
             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');
         }
         }
     }
     }